-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathnl.dart
More file actions
165 lines (141 loc) · 4.79 KB
/
Copy pathnl.dart
File metadata and controls
165 lines (141 loc) · 4.79 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
import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart';
import 'package:meta/meta.dart';
import '../../../frequency.dart';
import 'l10n.dart';
@immutable
class RruleL10nNl extends RruleL10n {
const RruleL10nNl._();
static Future<RruleL10nNl> create() async {
await initializeDateFormatting('nl');
return const RruleL10nNl._();
}
@override
String get locale => 'nl';
@override
String frequencyInterval(Frequency frequency, int interval) {
String plurals({required String one, required String plural}) {
return switch (interval) {
1 => one,
2 => 'Om de twee $plural',
_ => 'Om de $interval $plural',
};
}
return {
Frequency.secondly: plurals(one: 'Elke seconde', plural: 'seconden'),
Frequency.minutely: plurals(one: 'Elke minuut', plural: 'minuten'),
Frequency.hourly: plurals(one: 'Elk uur', plural: 'uren'),
Frequency.daily: plurals(one: 'Dagelijks', plural: 'dagen'),
Frequency.weekly: plurals(one: 'Wekelijks', plural: 'weken'),
Frequency.monthly: plurals(one: 'Maandelijks', plural: 'maanden'),
Frequency.yearly: plurals(one: 'Jaarlijks', plural: 'jaar'),
}[frequency]!;
}
@override
String until(DateTime until, Frequency frequency, {DateFormat? dateFormat}) {
final untilString = formatWithIntl(
() => dateFormat?.format(until) ?? DateFormat("EEEE d MMMM yyyy 'om' H:mm 'uur'", 'nl').format(until),
);
return ', tot $untilString';
}
@override
String count(int count) {
return switch (count) {
1 => ', één keer',
2 => ', twee keer',
_ => ', $count keer',
};
}
@override
String onInstances(String instances) => 'op de $instances';
@override
String inMonths(String months, {InOnVariant variant = InOnVariant.simple}) {
final suffix = variant == InOnVariant.also ? ' vallen' : '';
return '${_inVariant(variant)} $months$suffix';
}
@override
String inWeeks(String weeks, {InOnVariant variant = InOnVariant.simple}) {
final suffix = variant == InOnVariant.also ? ' vallen' : '';
return '${_inVariant(variant)} de $weeks week$suffix';
}
String _inVariant(InOnVariant variant) {
return switch (variant) {
InOnVariant.simple => 'in',
InOnVariant.also => 'die tevens in',
InOnVariant.instanceOf => 'van',
};
}
@override
String onDaysOfWeek(
String days, {
bool indicateFrequency = false,
DaysOfWeekFrequency? frequency = DaysOfWeekFrequency.monthly,
InOnVariant variant = InOnVariant.simple,
}) {
assert(variant != InOnVariant.also);
final frequencyString =
frequency == DaysOfWeekFrequency.monthly ? 'de maand' : 'het jaar';
final suffix = indicateFrequency ? ' van $frequencyString' : '';
return '${_onVariant(variant)} $days$suffix';
}
@override
String? get weekdaysString => 'weekdagen';
@override
String get everyXDaysOfWeekPrefix => 'elke ';
@override
String nthDaysOfWeek(Iterable<int> occurrences, String daysOfWeek) {
if (occurrences.isEmpty) return daysOfWeek;
final ordinals = list(
occurrences.map(ordinal).toList(),
ListCombination.conjunctiveShort,
);
return 'de $ordinals $daysOfWeek';
}
@override
String onDaysOfMonth(
String days, {
DaysOfVariant daysOfVariant = DaysOfVariant.dayAndFrequency,
InOnVariant variant = InOnVariant.simple,
}) {
final suffix = {
DaysOfVariant.simple: '',
DaysOfVariant.day: ' dag',
DaysOfVariant.dayAndFrequency: ' dag van de maand',
}[daysOfVariant];
final suffix2 = variant == InOnVariant.also ? ' zijn' : '';
return '${_onVariant(variant)} de $days$suffix$suffix2';
}
@override
String onDaysOfYear(
String days, {
InOnVariant variant = InOnVariant.simple,
}) {
final suffix = variant == InOnVariant.also ? ' zijn' : '';
return '${_onVariant(variant)} de $days dag van het jaar$suffix';
}
String _onVariant(InOnVariant variant) {
return switch (variant) {
InOnVariant.simple => 'op',
InOnVariant.also => 'die tevens',
InOnVariant.instanceOf => 'van',
};
}
@override
String list(List<String> items, ListCombination combination) {
final two = combination == ListCombination.disjunctive ? ' of ' : ' en ';
final end = combination == ListCombination.conjunctiveLong ? ', en ' : two;
return RruleL10n.defaultList(items, two: two, end: end);
}
@override
String ordinal(int number) {
assert(number != 0);
const special = {1: 'eerste', -1: 'laatste', -2: 'voorlaatste'};
final result = special[number];
if (result != null) return result;
final n = number.abs();
final remain = n % 100;
final string =
(remain <= 1 || remain == 8 || remain >= 20) ? '${n}ste' : '${n}de';
return number < 0 ? '$n-na-laatste' : string;
}
}