diff --git a/dev/tools/localization/gen_date_localizations.dart b/dev/tools/localization/gen_date_localizations.dart index 7e0c3276e0..7681619a8f 100644 --- a/dev/tools/localization/gen_date_localizations.dart +++ b/dev/tools/localization/gen_date_localizations.dart @@ -68,7 +68,6 @@ Future main(List rawArgs) async { final Map symbolFiles = _listIntlData(dateSymbolsDirectory); final Directory datePatternsDirectory = Directory(path.join(pathToIntl, 'src', 'data', 'dates', 'patterns')); final Map patternFiles = _listIntlData(datePatternsDirectory); - final List materialLocales = _materialLocales().toList(); final StringBuffer buffer = StringBuffer(); buffer.writeln( @@ -88,7 +87,7 @@ Future main(List rawArgs) async { /// supported by flutter_localizations.'''); buffer.writeln('const Map dateSymbols = {'); symbolFiles.forEach((String locale, File data) { - if (materialLocales.contains(locale)) + if (_supportedLocales().contains(locale)) buffer.writeln(_jsonToMapEntry(locale, json.decode(data.readAsStringSync()))); }); buffer.writeln('};'); @@ -100,7 +99,7 @@ Future main(List rawArgs) async { /// supported by flutter_localizations.'''); buffer.writeln('const Map> datePatterns = > {'); patternFiles.forEach((String locale, File data) { - if (materialLocales.contains(locale)) { + if (_supportedLocales().contains(locale)) { final Map patterns = json.decode(data.readAsStringSync()); buffer.writeln("'$locale': {"); patterns.forEach((String key, dynamic value) { @@ -154,14 +153,16 @@ String _jsonToMap(dynamic json) { throw 'Unsupported JSON type ${json.runtimeType} of value $json.'; } -Iterable _materialLocales() sync* { - final RegExp filenameRE = RegExp(r'material_(\w+)\.arb$'); - final Directory materialLocalizationsDirectory = Directory(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n')); - for (FileSystemEntity entity in materialLocalizationsDirectory.listSync()) { +Set _supportedLocales() { + final Set supportedLocales = {}; + final RegExp filenameRE = RegExp(r'(?:material|cupertino)_(\w+)\.arb$'); + final Directory supportedLocalesDirectory = Directory(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n')); + for (FileSystemEntity entity in supportedLocalesDirectory.listSync()) { final String filePath = entity.path; if (FileSystemEntity.isFileSync(filePath) && filenameRE.hasMatch(filePath)) - yield filenameRE.firstMatch(filePath)[1]; + supportedLocales.add(filenameRE.firstMatch(filePath)[1]); } + return supportedLocales; } Map _listIntlData(Directory directory) {