-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathl10n.dart
More file actions
116 lines (94 loc) · 3.21 KB
/
Copy pathl10n.dart
File metadata and controls
116 lines (94 loc) · 3.21 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
import 'package:intl/intl.dart';
import 'package:meta/meta.dart';
import '../../../frequency.dart';
import '../../../recurrence_rule.dart';
import '../../../utils.dart';
import 'en.dart';
export 'en.dart';
export 'nl.dart';
export 'pt_BR.dart';
/// Contains localized strings used by [RecurrenceRule.toText].
///
/// Currently, only English is supported: [RruleL10nEn].
@immutable
abstract class RruleL10n {
const RruleL10n();
String get locale;
String formatWithIntl(String Function() formatter) =>
Intl.withLocale(locale, formatter) as String;
String frequencyInterval(Frequency frequency, int interval);
String until(DateTime until, Frequency frequency, {DateFormat? dateFormat});
String count(int count);
String range(String start, String end) => '$start – $end';
String onInstances(String instances);
String inMonths(String months, {InOnVariant variant = InOnVariant.simple});
String month(int month) =>
formatWithIntl(() => DateFormat().dateSymbols.MONTHS[month - 1]);
String inWeeks(String weeks, {InOnVariant variant = InOnVariant.simple});
Set<int> get weekdays => {
DateTime.monday,
DateTime.tuesday,
DateTime.wednesday,
DateTime.thursday,
DateTime.friday,
};
String onDaysOfWeek(
String days, {
bool indicateFrequency = false,
DaysOfWeekFrequency? frequency = DaysOfWeekFrequency.monthly,
InOnVariant variant = InOnVariant.simple,
});
String? get weekdaysString;
String get everyXDaysOfWeekPrefix;
String dayOfWeek(int dayOfWeek) {
assert(dayOfWeek.isValidRruleDayOfWeek);
return formatWithIntl(
() => DateFormat().dateSymbols.WEEKDAYS[dayOfWeek % 7],
);
}
String nthDaysOfWeek(Iterable<int> occurrences, String daysOfWeek);
String onDaysOfMonth(
String days, {
DaysOfVariant daysOfVariant = DaysOfVariant.dayAndFrequency,
InOnVariant variant = InOnVariant.simple,
});
String onDaysOfYear(String days, {InOnVariant variant = InOnVariant.simple});
String list(List<String> items, ListCombination combination);
/// Generates a formatted list from items similar to the
/// [Unicode-Proposal](http://cldr.unicode.org/development/development-process/design-proposals/list-formatting).
static String defaultList(
List<String> items, {
required String two,
String start = ', ',
String middle = ', ',
required String end,
}) {
switch (items.length) {
case 0:
throw ArgumentError('items must not be empty.');
case 1:
return items.first;
case 2:
return '${items.first}$two${items[1]}';
default:
final output = StringBuffer(items.first);
output
..write(start)
..write(items[1]);
for (final entry in items.sublist(2, items.length - 1)) {
output
..write(middle)
..write(entry);
}
output
..write(end)
..write(items.last);
return output.toString();
}
}
String ordinal(int number);
}
enum InOnVariant { simple, also, instanceOf }
enum DaysOfWeekFrequency { monthly, yearly }
enum DaysOfVariant { simple, day, dayAndFrequency }
enum ListCombination { conjunctiveShort, conjunctiveLong, disjunctive }