Use correct locale for CupertinoDatePicker weekday (#151494)
#120052 introduces the `showDayOfWeek` flag to `CupertinoDatePicker` for mode `CupertinoDatePickerMode.date`, but the default `en` locale from `DefaultCupertinoLocalizations` is always used for the day of the week:
5103d75743/packages/flutter_localizations/lib/src/cupertino_localizations.dart (L116-L119)
This PR introduces a new `intl.DateFormat` `weekdayFormat` to replace the default with the abbreviated weekday for any supported locales.
| Before | After |
| --- | --- |
| <img width="379" alt="Screenshot 2024-07-09 at 5 08 43â¯PM" src="https://github.com/flutter/flutter/assets/77553258/d6899c6b-bd0a-4484-a6a8-3ef1512aeae1"> | <img width="379" alt="Screenshot 2024-07-09 at 5 08 11â¯PM" src="https://github.com/flutter/flutter/assets/77553258/f320c634-80d1-4f3b-adfd-ed85a9dfc3f6"> |
Fixes #141875
This commit is contained in:
@@ -239,6 +239,15 @@ void main() {
|
||||
expect(localizations, isA<CupertinoLocalizationZh>());
|
||||
expect(localizations.lookUpButtonLabel, '查询');
|
||||
});
|
||||
|
||||
testWidgets('localizations.datePickerDayOfMonth uses the current locale for weekdays', (WidgetTester tester) async {
|
||||
const Locale locale = Locale('zh');
|
||||
expect(GlobalCupertinoLocalizations.delegate.isSupported(locale), isTrue);
|
||||
final CupertinoLocalizations localizations = await GlobalCupertinoLocalizations.delegate.load(locale);
|
||||
expect(localizations, isA<CupertinoLocalizationZh>());
|
||||
expect(localizations.datePickerDayOfMonth(1), '1日');
|
||||
expect(localizations.datePickerDayOfMonth(1, 2), '周二 1日');
|
||||
});
|
||||
}
|
||||
|
||||
class _FakeEditableText extends EditableText {
|
||||
|
||||
Reference in New Issue
Block a user