123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- import 'dart:io';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/foundation.dart';
- class MyLocalizationsDelegate extends LocalizationsDelegate<CupertinoLocalizations> {
- const MyLocalizationsDelegate();
- @override
- bool isSupported(Locale locale) => locale.languageCode == 'zh';
- @override
- Future<CupertinoLocalizations> load(Locale locale) => ZhCupertinoLocalizations.load(locale);
- @override
- bool shouldReload(MyLocalizationsDelegate old) => false;
- @override
- String toString() => 'DefaultCupertinoLocalizations.delegate(zh)';
- }
- class ZhCupertinoLocalizations implements CupertinoLocalizations {
- const ZhCupertinoLocalizations();
- static const List<String> _shortWeekdays = <String>[
- '周一',
- '周二',
- '周三',
- '周四',
- '周五',
- '周六',
- '周日',
- ];
- static const List<String> _shortMonths = <String>[
- '1月',
- '2月',
- '3月',
- '4月',
- '5月',
- '6月',
- '7月',
- '8月',
- '9月',
- '10月',
- '11月',
- '12月',
- ];
- static const List<String> _months = <String>[
- '1月',
- '2月',
- '3月',
- '4月',
- '5月',
- '6月',
- '7月',
- '8月',
- '9月',
- '10月',
- '11月',
- '12月',
- ];
- @override
- String datePickerYear(int yearIndex) => yearIndex.toString();
- @override
- String datePickerMonth(int monthIndex) => _months[monthIndex - 1];
- @override
- String datePickerHour(int hour) => hour.toString();
- @override
- String datePickerHourSemanticsLabel(int hour) => "$hour o'clock";
- @override
- String datePickerMinute(int minute) => minute.toString().padLeft(2, '0');
- @override
- String datePickerMinuteSemanticsLabel(int minute) {
- if (minute == 1) return '1 分';
- return '$minute 分';
- }
- @override
- String datePickerMediumDate(DateTime date) {
- return '${_shortWeekdays[date.weekday - DateTime.monday]} '
- '${_shortMonths[date.month - DateTime.january]} '
- '${date.day.toString().padRight(2)}';
- }
- @override
- DatePickerDateOrder get datePickerDateOrder => DatePickerDateOrder.mdy;
- @override
- DatePickerDateTimeOrder get datePickerDateTimeOrder =>
- DatePickerDateTimeOrder.date_time_dayPeriod;
- @override
- String get anteMeridiemAbbreviation => '上午';
- @override
- String get postMeridiemAbbreviation => '下午';
- @override
- String get todayLabel => '今天';
- @override
- String get alertDialogLabel => 'Alert';
- @override
- String timerPickerHour(int hour) => hour.toString();
- @override
- String timerPickerMinute(int minute) => minute.toString();
- @override
- String timerPickerSecond(int second) => second.toString();
- @override
- String timerPickerHourLabel(int hour) => hour == 1 ? '小时' : '小时';
- @override
- String timerPickerMinuteLabel(int minute) => '分.';
- @override
- String timerPickerSecondLabel(int second) => '秒.';
- @override
- String get cutButtonLabel => '剪贴';
- @override
- String get copyButtonLabel => '拷贝';
- @override
- String get pasteButtonLabel => '粘贴';
- @override
- String get selectAllButtonLabel => '选择全部';
- static Future<CupertinoLocalizations> load(Locale locale) {
- return SynchronousFuture<CupertinoLocalizations>(
- const ZhCupertinoLocalizations());
- }
- static const LocalizationsDelegate<CupertinoLocalizations> delegate = MyLocalizationsDelegate();
- @override
- String get modalBarrierDismissLabel => '';
- @override
- String tabSemanticsLabel({required int tabIndex, required int tabCount}) => '';
- @override
- List<String> get timerPickerHourLabels => [];
- @override
- List<String> get timerPickerMinuteLabels => [];
- @override
- List<String> get timerPickerSecondLabels => [];
- @override
- String get searchTextFieldPlaceholderLabel => '';
- @override
- String datePickerDayOfMonth(int dayIndex, [int? weekDay]) {
- return '$dayIndex';
- }
- @override
- String get noSpellCheckReplacementsLabel => "";
- }
|