@@ -77,7 +77,7 @@ Future<Null> main(List<String> rawArgs) async {
77
77
78
78
// This file has been automatically generated. Please do not edit it manually.
79
79
// To regenerate run (omit -w to print to console instead of the file):
80
- // dart dev/tools/gen_date_localizations.dart -w
80
+ // dart --enable-asserts dev/tools/gen_date_localizations.dart -w
81
81
82
82
'''
83
83
);
@@ -88,10 +88,19 @@ Future<Null> main(List<String> rawArgs) async {
88
88
});
89
89
buffer.writeln ('};' );
90
90
91
- buffer.writeln ('const Map<String, dynamic> datePatterns = const <String, dynamic> {' );
91
+ // Note: code that uses datePatterns expects it to contain values of type
92
+ // Map<String, String> not Map<String, dynamic>.
93
+ buffer.writeln ('const Map<String, Map<String, String>> datePatterns = const <String, Map<String, String>> {' );
92
94
patternFiles.forEach ((String locale, File data) {
93
- if (materialLocales.contains (locale))
94
- buffer.writeln (_jsonToMapEntry (locale, JSON .decode (data.readAsStringSync ())));
95
+ if (materialLocales.contains (locale)) {
96
+ final Map <String , dynamic > patterns = JSON .decode (data.readAsStringSync ());
97
+ buffer.writeln ("'$locale ': const <String, String>{" );
98
+ patterns.forEach ((String key, dynamic value) {
99
+ assert (value is String );
100
+ buffer.writeln (_jsonToMapEntry (key, value));
101
+ });
102
+ buffer.writeln ('},' );
103
+ }
95
104
});
96
105
buffer.writeln ('};' );
97
106
@@ -148,13 +157,16 @@ Iterable<String> _materialLocales() sync* {
148
157
}
149
158
150
159
Map <String , File > _listIntlData (Directory directory) {
151
- final Map <String , File > result = < String , File > {};
160
+ final Map <String , File > localeFiles = < String , File > {};
152
161
for (FileSystemEntity entity in directory.listSync ()) {
153
162
final String filePath = entity.path;
154
163
if (FileSystemEntity .isFileSync (filePath) && filePath.endsWith ('.json' )) {
155
164
final String locale = path.basenameWithoutExtension (filePath);
156
- result [locale] = entity;
165
+ localeFiles [locale] = entity;
157
166
}
158
167
}
159
- return result;
168
+
169
+ final List <String > locales = localeFiles.keys.toList (growable: false );
170
+ locales.sort ();
171
+ return new Map <String , File >.fromIterable (locales, value: (dynamic locale) => localeFiles[locale]);
160
172
}
0 commit comments