Repository navigation
Expand file tree
/
Copy pathlocalizations.dart
More file actions
593 lines (478 loc) · 18.8 KB
/
Copy pathlocalizations.dart
File metadata and controls
593 lines (478 loc) · 18.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// @docImport 'bottom_tab_bar.dart';
/// @docImport 'date_picker.dart';
/// @docImport 'expansion_tile.dart';
/// @docImport 'nav_bar.dart';
/// @docImport 'search_field.dart';
library;
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'debug.dart';
// Examples can assume:
// late BuildContext context;
/// Determines the order of the columns inside [CupertinoDatePicker] in
/// time and date time mode.
enum DatePickerDateTimeOrder {
/// Order of the columns, from left to right: date, hour, minute, am/pm.
///
/// Example: Fri Aug 31 | 02 | 08 | PM.
date_time_dayPeriod,
/// Order of the columns, from left to right: date, am/pm, hour, minute.
///
/// Example: Fri Aug 31 | PM | 02 | 08.
date_dayPeriod_time,
/// Order of the columns, from left to right: hour, minute, am/pm, date.
///
/// Example: 02 | 08 | PM | Fri Aug 31.
time_dayPeriod_date,
/// Order of the columns, from left to right: am/pm, hour, minute, date.
///
/// Example: PM | 02 | 08 | Fri Aug 31.
dayPeriod_time_date,
}
/// Determines the order of the columns inside [CupertinoDatePicker] in date mode.
enum DatePickerDateOrder {
/// Order of the columns, from left to right: day, month, year.
///
/// Example: 12 | March | 1996.
dmy,
/// Order of the columns, from left to right: month, day, year.
///
/// Example: March | 12 | 1996.
mdy,
/// Order of the columns, from left to right: year, month, day.
///
/// Example: 1996 | March | 12.
ymd,
/// Order of the columns, from left to right: year, day, month.
///
/// Example: 1996 | 12 | March.
ydm,
}
/// Defines the localized resource values used by the Cupertino widgets.
///
/// See also:
///
/// * [DefaultCupertinoLocalizations], the default, English-only, implementation
/// of this interface.
abstract class CupertinoLocalizations {
/// Year that is shown in [CupertinoDatePicker] spinner corresponding to the
/// given year index.
///
/// Examples: datePickerYear(1) in:
///
/// - US English: 2018
/// - Korean: 2018년
// The global version uses date symbols data from the intl package.
String datePickerYear(int yearIndex);
/// Month that is shown in [CupertinoDatePicker] spinner corresponding to
/// the given month index.
///
/// Examples: datePickerMonth(1) in:
///
/// - US English: January
/// - Korean: 1월
/// - Russian: января
// The global version uses date symbols data from the intl package.
String datePickerMonth(int monthIndex);
/// Month that is shown in [CupertinoDatePicker] spinner corresponding to
/// the given month index in [CupertinoDatePickerMode.monthYear] mode.
///
/// This is distinct from [datePickerMonth] because in some languages, like Russian,
/// the name of a month takes a different form depending
/// on whether it is preceded by a day or whether it stands alone.
///
/// Examples: datePickerMonth(1) in:
///
/// - US English: January
/// - Korean: 1월
/// - Russian: Январь
// The global version uses date symbols data from the intl package.
String datePickerStandaloneMonth(int monthIndex);
/// Day of month that is shown in [CupertinoDatePicker] spinner corresponding
/// to the given day index.
///
/// If weekDay is provided then it will also show weekday name alongside the numerical day.
///
/// Examples: datePickerDayOfMonth(1) in:
///
/// - US English: 1
/// - Korean: 1일
/// Examples: datePickerDayOfMonth(1, 1) in:
///
/// - US English: Mon 1
// The global version uses date symbols data from the intl package.
String datePickerDayOfMonth(int dayIndex, [int? weekDay]);
/// The medium-width date format that is shown in [CupertinoDatePicker]
/// spinner. Abbreviates month and days of week.
///
/// Examples:
///
/// - US English: Wed Sep 27
/// - Russian: ср сент. 27
// The global version is based on intl package's DateFormat.MMMEd.
String datePickerMediumDate(DateTime date);
/// Hour that is shown in [CupertinoDatePicker] spinner corresponding
/// to the given hour value.
///
/// Examples: datePickerHour(1) in:
///
/// - US English: 1
/// - Arabic: ٠١
// The global version uses date symbols data from the intl package.
String datePickerHour(int hour);
/// Semantics label for the given hour value in [CupertinoDatePicker].
// The global version uses the translated string from the arb file.
String? datePickerHourSemanticsLabel(int hour);
/// Minute that is shown in [CupertinoDatePicker] spinner corresponding
/// to the given minute value.
///
/// Examples: datePickerMinute(1) in:
///
/// - US English: 01
/// - Arabic: ٠١
// The global version uses date symbols data from the intl package.
String datePickerMinute(int minute);
/// Semantics label for the given minute value in [CupertinoDatePicker].
// The global version uses the translated string from the arb file.
String? datePickerMinuteSemanticsLabel(int minute);
/// The order of the date elements that will be shown in [CupertinoDatePicker].
// The global version uses the translated string from the arb file.
DatePickerDateOrder get datePickerDateOrder;
/// The order of the time elements that will be shown in [CupertinoDatePicker].
// The global version uses the translated string from the arb file.
DatePickerDateTimeOrder get datePickerDateTimeOrder;
/// The abbreviation for ante meridiem (before noon) shown in the time picker.
// The global version uses the translated string from the arb file.
String get anteMeridiemAbbreviation;
/// The abbreviation for post meridiem (after noon) shown in the time picker.
// The global version uses the translated string from the arb file.
String get postMeridiemAbbreviation;
/// Label shown in date pickers when the date is today.
// The global version uses the translated string from the arb file.
String get todayLabel;
/// The term used by the system to announce dialog alerts.
// The global version uses the translated string from the arb file.
String get alertDialogLabel;
/// The accessibility label used on a tab in a [CupertinoTabBar].
///
/// This message describes the index of the selected tab and how many tabs
/// there are, e.g. 'tab, 1 of 2' in United States English.
///
/// `tabIndex` and `tabCount` must be greater than or equal to one.
String tabSemanticsLabel({required int tabIndex, required int tabCount});
/// Hour that is shown in [CupertinoTimerPicker] corresponding to
/// the given hour value.
///
/// Examples: timerPickerHour(1) in:
///
/// - US English: 1
/// - Arabic: ١
// The global version uses date symbols data from the intl package.
String timerPickerHour(int hour);
/// Minute that is shown in [CupertinoTimerPicker] corresponding to
/// the given minute value.
///
/// Examples: timerPickerMinute(1) in:
///
/// - US English: 1
/// - Arabic: ١
// The global version uses date symbols data from the intl package.
String timerPickerMinute(int minute);
/// Second that is shown in [CupertinoTimerPicker] corresponding to
/// the given second value.
///
/// Examples: timerPickerSecond(1) in:
///
/// - US English: 1
/// - Arabic: ١
// The global version uses date symbols data from the intl package.
String timerPickerSecond(int second);
/// Label that appears next to the hour picker in
/// [CupertinoTimerPicker] when selected hour value is `hour`.
/// This function will deal with pluralization based on the `hour` parameter.
// The global version uses the translated string from the arb file.
String? timerPickerHourLabel(int hour);
/// All possible hour labels that appears next to the hour picker in
/// [CupertinoTimerPicker]
List<String> get timerPickerHourLabels;
/// Label that appears next to the minute picker in
/// [CupertinoTimerPicker] when selected minute value is `minute`.
/// This function will deal with pluralization based on the `minute` parameter.
// The global version uses the translated string from the arb file.
String? timerPickerMinuteLabel(int minute);
/// All possible minute labels that appears next to the minute picker in
/// [CupertinoTimerPicker]
List<String> get timerPickerMinuteLabels;
/// Label that appears next to the minute picker in
/// [CupertinoTimerPicker] when selected minute value is `second`.
/// This function will deal with pluralization based on the `second` parameter.
// The global version uses the translated string from the arb file.
String? timerPickerSecondLabel(int second);
/// All possible second labels that appears next to the second picker in
/// [CupertinoTimerPicker]
List<String> get timerPickerSecondLabels;
/// The term used for cutting.
// The global version uses the translated string from the arb file.
String get cutButtonLabel;
/// The term used for copying.
// The global version uses the translated string from the arb file.
String get copyButtonLabel;
/// The term used for pasting.
// The global version uses the translated string from the arb file.
String get pasteButtonLabel;
/// The term used for clearing a field.
// The global version uses the translated string from the arb file.
String get clearButtonLabel;
/// Label that appears in the Cupertino toolbar when the spell checker
/// couldn't find any replacements for the current word.
// The global version uses the translated string from the arb file.
String get noSpellCheckReplacementsLabel;
/// The term used for selecting everything.
// The global version uses the translated string from the arb file.
String get selectAllButtonLabel;
/// The term used for looking up a selection.
// The global version uses the translated string from the arb file.
String get lookUpButtonLabel;
/// The term used for launching a web search on a selection.
// The global version uses the translated string from the arb file.
String get searchWebButtonLabel;
/// The term used for launching a web search on a selection.
// The global version uses the translated string from the arb file.
String get shareButtonLabel;
/// The default placeholder used in [CupertinoSearchTextField].
// The global version uses the translated string from the arb file.
String get searchTextFieldPlaceholderLabel;
/// Label read out by accessibility tools (VoiceOver) for a modal
/// barrier to indicate that a tap dismisses the barrier.
///
/// A modal barrier can for example be found behind an alert or popup to block
/// user interaction with elements behind it.
String get modalBarrierDismissLabel;
/// Label read out by accessibility tools (VoiceOver) for a context menu to
/// indicate that a tap outside dismisses the context menu.
String get menuDismissLabel;
/// The label for the cancel button in modal views, used in [CupertinoNavigationBar] and [CupertinoSliverNavigationBar].
String get cancelButtonLabel;
/// The label for the back button, used in [CupertinoNavigationBar] and [CupertinoSliverNavigationBar].
String get backButtonLabel;
/// The semantics hint to describe the tap action on an expanded
/// [CupertinoExpansionTile] on iOS and macOS. This is appended to the [collapsedHint]
/// hint to provide a more detailed description of the action, e.g. "Expanded
/// double tap to collapse".
String get expansionTileExpandedHint => 'double tap to collapse';
/// The semantics hint to describe the tap action on a collapsed
/// [CupertinoExpansionTile] on iOS and macOS. This is appended to the [expandedHint]
/// hint to provide a more detailed description of the action, e.g. "Collapsed
/// double tap to expand".
String get expansionTileCollapsedHint => 'double tap to expand';
/// The semantics hint to describe the tap action on an expanded [CupertinoExpansionTile].
String get expansionTileExpandedTapHint => 'Collapse';
/// The semantics hint to describe the tap action on a collapsed [CupertinoExpansionTile].
String get expansionTileCollapsedTapHint => 'Expand for more details';
/// The semantics hint to describe the [CupertinoExpansionTile] expanded state.
String get expandedHint => 'Collapsed';
/// The semantics hint to describe the [CupertinoExpansionTile] collapsed state.
String get collapsedHint => 'Expanded';
/// The `CupertinoLocalizations` from the closest [Localizations] instance
/// that encloses the given context.
///
/// If no [CupertinoLocalizations] are available in the given `context`, this
/// method throws an exception.
///
/// This method is just a convenient shorthand for:
/// `Localizations.of<CupertinoLocalizations>(context, CupertinoLocalizations)!`.
///
/// References to the localized resources defined by this class are typically
/// written in terms of this method. For example:
///
/// ```dart
/// CupertinoLocalizations.of(context).anteMeridiemAbbreviation;
/// ```
static CupertinoLocalizations of(BuildContext context) {
assert(debugCheckHasCupertinoLocalizations(context));
return Localizations.of<CupertinoLocalizations>(context, CupertinoLocalizations)!;
}
}
class _CupertinoLocalizationsDelegate extends LocalizationsDelegate<CupertinoLocalizations> {
const _CupertinoLocalizationsDelegate();
@override
bool isSupported(Locale locale) => locale.languageCode == 'en';
@override
Future<CupertinoLocalizations> load(Locale locale) => DefaultCupertinoLocalizations.load(locale);
@override
bool shouldReload(_CupertinoLocalizationsDelegate old) => false;
@override
String toString() => 'DefaultCupertinoLocalizations.delegate(en_US)';
}
/// US English strings for the Cupertino widgets.
class DefaultCupertinoLocalizations implements CupertinoLocalizations {
/// Constructs an object that defines the cupertino widgets' localized strings
/// for US English (only).
///
/// [LocalizationsDelegate] implementations typically call the static [load]
/// function, rather than constructing this class directly.
const DefaultCupertinoLocalizations();
/// Short version of days of week.
static const List<String> _shortWeekdays = <String>[
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun',
];
static const List<String> _shortMonths = <String>[
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec',
];
static const List<String> _months = <String>[
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December',
];
@override
String datePickerYear(int yearIndex) => yearIndex.toString();
@override
String datePickerMonth(int monthIndex) => _months[monthIndex - 1];
@override
String datePickerStandaloneMonth(int monthIndex) => _months[monthIndex - 1];
@override
String datePickerDayOfMonth(int dayIndex, [int? weekDay]) {
if (weekDay != null) {
return ' ${_shortWeekdays[weekDay - DateTime.monday]} $dayIndex ';
}
return dayIndex.toString();
}
@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 minute';
}
return '$minute minutes';
}
@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 => 'AM';
@override
String get postMeridiemAbbreviation => 'PM';
@override
String get todayLabel => 'Today';
@override
String get alertDialogLabel => 'Alert';
@override
String tabSemanticsLabel({required int tabIndex, required int tabCount}) {
assert(tabIndex >= 1);
assert(tabCount >= 1);
return 'Tab $tabIndex of $tabCount';
}
@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 ? 'hour' : 'hours';
@override
List<String> get timerPickerHourLabels => const <String>['hour', 'hours'];
@override
String timerPickerMinuteLabel(int minute) => 'min.';
@override
List<String> get timerPickerMinuteLabels => const <String>['min.'];
@override
String timerPickerSecondLabel(int second) => 'sec.';
@override
List<String> get timerPickerSecondLabels => const <String>['sec.'];
@override
String get cutButtonLabel => 'Cut';
@override
String get copyButtonLabel => 'Copy';
@override
String get pasteButtonLabel => 'Paste';
@override
String get clearButtonLabel => 'Clear';
@override
String get noSpellCheckReplacementsLabel => 'No Replacements Found';
@override
String get selectAllButtonLabel => 'Select All';
@override
String get lookUpButtonLabel => 'Look Up';
@override
String get searchWebButtonLabel => 'Search Web';
@override
String get shareButtonLabel => 'Share...';
@override
String get searchTextFieldPlaceholderLabel => 'Search';
@override
String get modalBarrierDismissLabel => 'Dismiss';
@override
String get menuDismissLabel => 'Dismiss menu';
@override
String get cancelButtonLabel => 'Cancel';
@override
String get backButtonLabel => 'Back';
@override
String get expansionTileExpandedHint => 'double tap to collapse';
@override
String get expansionTileCollapsedHint => 'double tap to expand';
@override
String get expansionTileExpandedTapHint => 'Collapse';
@override
String get expansionTileCollapsedTapHint => 'Expand for more details';
@override
String get expandedHint => 'Collapsed';
@override
String get collapsedHint => 'Expanded';
/// Creates an object that provides US English resource values for the
/// cupertino library widgets.
///
/// The [locale] parameter is ignored.
///
/// This method is typically used to create a [LocalizationsDelegate].
static Future<CupertinoLocalizations> load(Locale locale) {
return SynchronousFuture<CupertinoLocalizations>(const DefaultCupertinoLocalizations());
}
/// A [LocalizationsDelegate] that uses [DefaultCupertinoLocalizations.load]
/// to create an instance of this class.
static const LocalizationsDelegate<CupertinoLocalizations> delegate =
_CupertinoLocalizationsDelegate();
}