diff --git a/dev/tools/localization/gen_l10n.dart b/dev/tools/localization/gen_l10n.dart index e8e4634790..a056351df9 100644 --- a/dev/tools/localization/gen_l10n.dart +++ b/dev/tools/localization/gen_l10n.dart @@ -149,6 +149,10 @@ const String pluralMethodTemplate = ''' } '''; +int sortFilesByPath (FileSystemEntity a, FileSystemEntity b) { + return a.path.compareTo(b.path); +} + List genMethodParameters(Map bundle, String key, String type) { final Map attributesMap = bundle['@$key']; if (attributesMap != null && attributesMap.containsKey('placeholders')) { @@ -384,7 +388,7 @@ Future main(List arguments) async { final Set supportedLanguageCodes = {}; final Set supportedLocales = {}; - for (FileSystemEntity entity in l10nDirectory.listSync()) { + for (FileSystemEntity entity in l10nDirectory.listSync().toList()..sort(sortFilesByPath)) { final String entityPath = entity.path; if (FileSystemEntity.isFileSync(entityPath)) { @@ -435,7 +439,7 @@ Future main(List arguments) async { final RegExp pluralValueRE = RegExp(r'^\s*\{[\w\s,]*,\s*plural\s*,'); - for (String key in bundle.keys) { + for (String key in bundle.keys.toList()..sort()) { if (key.startsWith('@')) continue; if (!_isValidGetterAndMethodName(key)) diff --git a/examples/stocks/lib/i18n/messages_all.dart b/examples/stocks/lib/i18n/messages_all.dart index 2ea26553b6..867afc7704 100644 --- a/examples/stocks/lib/i18n/messages_all.dart +++ b/examples/stocks/lib/i18n/messages_all.dart @@ -15,21 +15,21 @@ import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/src/intl_helpers.dart'; -import 'messages_es_ES.dart' as messages_es_es; import 'messages_en_US.dart' as messages_en_us; +import 'messages_es_ES.dart' as messages_es_es; typedef Future LibraryLoader(); Map _deferredLibraries = { - 'es_ES': () => new Future.value(null), 'en_US': () => new Future.value(null), + 'es_ES': () => new Future.value(null), }; MessageLookupByLibrary _findExact(String localeName) { switch (localeName) { - case 'es_ES': - return messages_es_es.messages; case 'en_US': return messages_en_us.messages; + case 'es_ES': + return messages_es_es.messages; default: return null; } diff --git a/examples/stocks/lib/i18n/stock_strings.dart b/examples/stocks/lib/i18n/stock_strings.dart index dee4073c94..30d2ba2885 100644 --- a/examples/stocks/lib/i18n/stock_strings.dart +++ b/examples/stocks/lib/i18n/stock_strings.dart @@ -65,7 +65,7 @@ class StockStrings { static Future load(Locale locale) { return initializeMessages(locale.toString()) - .then((void _) => StockStrings(locale)); + .then((_) => StockStrings(locale)); } static StockStrings of(BuildContext context) { @@ -89,19 +89,10 @@ class StockStrings { /// A list of this localizations delegate's supported locales. static const List supportedLocales = [ - Locale('es', 'ES'), Locale('en', 'US'), + Locale('es', 'ES'), ]; - String get title { - return Intl.message( - r'Stocks', - locale: _localeName, - name: 'title', - desc: r'Title for the Stocks application' - ); - } - String get market { return Intl.message( r'MARKET', @@ -120,6 +111,15 @@ class StockStrings { ); } + String get title { + return Intl.message( + r'Stocks', + locale: _localeName, + name: 'title', + desc: r'Title for the Stocks application' + ); + } + } class _StockStringsDelegate extends LocalizationsDelegate { @@ -129,7 +129,7 @@ class _StockStringsDelegate extends LocalizationsDelegate { Future load(Locale locale) => StockStrings.load(locale); @override - bool isSupported(Locale locale) => ['es', 'en'].contains(locale.languageCode); + bool isSupported(Locale locale) => ['en', 'es'].contains(locale.languageCode); @override bool shouldReload(_StockStringsDelegate old) => false;