Unverified Commit 2b498567 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

Sort Localization generation output (#44743)

* Sort Localization generation output

- When creating locales that were assumed from existing locales, the
file that is used is non-deterministic. This adds a sort to the iterator
to ensure that the same existing locale is used to generate the assumed
locale
- When generating material, cupertino and date localizations, the generated getters were not sorted. This
introduces an alphabetic sort

* remove main.dart.snapshot
parent d39e2bb7
......@@ -99,7 +99,7 @@ String generateArbBasedLocalizationSubclasses({
}
languageToLocales[locale.languageCode] ??= <LocaleInfo>[];
languageToLocales[locale.languageCode].add(locale);
allResourceIdentifiers.addAll(localeToResources[locale].keys);
allResourceIdentifiers.addAll(localeToResources[locale].keys.toList()..sort());
}
// We generate one class per supported language (e.g.
......@@ -155,7 +155,7 @@ String generateArbBasedLocalizationSubclasses({
));
output.writeln(generateConstructor(scriptBaseLocale));
final Map<String, String> scriptResources = localeToResources[scriptBaseLocale];
for (String key in scriptResources.keys) {
for (String key in scriptResources.keys.toList()..sort()) {
if (languageResources[key] == scriptResources[key])
continue;
final Map<String, dynamic> attributes = localeToResourceAttributes[canonicalLocale][key];
......
......@@ -12,6 +12,10 @@ import 'package:meta/meta.dart';
typedef HeaderGenerator = String Function(String regenerateInstructions);
typedef ConstructorGenerator = String Function(LocaleInfo locale);
int sortFilesByPath (FileSystemEntity a, FileSystemEntity b) {
return a.path.compareTo(b.path);
}
/// Simple data class to hold parsed locale. Does not promise validity of any data.
class LocaleInfo implements Comparable<LocaleInfo> {
LocaleInfo({
......@@ -153,7 +157,7 @@ void loadMatchingArbsIntoBundleMaps({
/// overwrite the existing assumed data.
final Set<LocaleInfo> assumedLocales = <LocaleInfo>{};
for (FileSystemEntity entity in directory.listSync()) {
for (FileSystemEntity entity in directory.listSync().toList()..sort(sortFilesByPath)) {
final String entityPath = entity.path;
if (FileSystemEntity.isFileSync(entityPath) && filenamePattern.hasMatch(entityPath)) {
final String localeString = filenamePattern.firstMatch(entityPath)[1];
......
......@@ -10685,19 +10685,19 @@ class CupertinoLocalizationSrLatn extends CupertinoLocalizationSr {
);
@override
String get datePickerHourSemanticsLabelFew => r'$hour sata';
String get alertDialogLabel => r'Obaveštenje';
@override
String get datePickerMinuteSemanticsLabelFew => r'$minute minuta';
String get anteMeridiemAbbreviation => r'pre podne';
@override
String get timerPickerHourLabelFew => r'sata';
String get copyButtonLabel => r'Kopiraj';
@override
String get timerPickerMinuteLabelFew => r'min';
String get cutButtonLabel => r'Iseci';
@override
String get timerPickerSecondLabelFew => r'sek';
String get datePickerHourSemanticsLabelFew => r'$hour sata';
@override
String get datePickerHourSemanticsLabelOne => r'$hour sat';
......@@ -10705,6 +10705,9 @@ class CupertinoLocalizationSrLatn extends CupertinoLocalizationSr {
@override
String get datePickerHourSemanticsLabelOther => r'$hour sati';
@override
String get datePickerMinuteSemanticsLabelFew => r'$minute minuta';
@override
String get datePickerMinuteSemanticsLabelOne => r'1 minut';
......@@ -10712,16 +10715,16 @@ class CupertinoLocalizationSrLatn extends CupertinoLocalizationSr {
String get datePickerMinuteSemanticsLabelOther => r'$minute minuta';
@override
String get anteMeridiemAbbreviation => r'pre podne';
String get pasteButtonLabel => r'Nalepi';
@override
String get postMeridiemAbbreviation => r'po podne';
@override
String get todayLabel => r'Danas';
String get selectAllButtonLabel => r'Izaberi sve';
@override
String get alertDialogLabel => r'Obaveštenje';
String get timerPickerHourLabelFew => r'sata';
@override
String get timerPickerHourLabelOne => r'sat';
......@@ -10730,28 +10733,25 @@ class CupertinoLocalizationSrLatn extends CupertinoLocalizationSr {
String get timerPickerHourLabelOther => r'sati';
@override
String get timerPickerMinuteLabelOne => r'min';
@override
String get timerPickerMinuteLabelOther => r'min';
String get timerPickerMinuteLabelFew => r'min';
@override
String get timerPickerSecondLabelOne => r'sek';
String get timerPickerMinuteLabelOne => r'min';
@override
String get timerPickerSecondLabelOther => r'sek';
String get timerPickerMinuteLabelOther => r'min';
@override
String get cutButtonLabel => r'Iseci';
String get timerPickerSecondLabelFew => r'sek';
@override
String get copyButtonLabel => r'Kopiraj';
String get timerPickerSecondLabelOne => r'sek';
@override
String get pasteButtonLabel => r'Nalepi';
String get timerPickerSecondLabelOther => r'sek';
@override
String get selectAllButtonLabel => r'Izaberi sve';
String get todayLabel => r'Danas';
}
/// The translations for Swedish (`sv`).
......@@ -12586,46 +12586,46 @@ class CupertinoLocalizationZhHant extends CupertinoLocalizationZh {
);
@override
String get datePickerHourSemanticsLabelOne => r'$hour 點';
String get alertDialogLabel => r'通知';
@override
String get datePickerHourSemanticsLabelOther => r'$hour 點';
String get copyButtonLabel => r'複製';
@override
String get datePickerMinuteSemanticsLabelOne => r'1 分鐘';
String get cutButtonLabel => r'剪下';
@override
String get datePickerMinuteSemanticsLabelOther => r'$minute 分鐘';
String get datePickerDateTimeOrderString => r'date_dayPeriod_time';
@override
String get datePickerDateTimeOrderString => r'date_dayPeriod_time';
String get datePickerHourSemanticsLabelOne => r'$hour 點';
@override
String get alertDialogLabel => r'通知';
String get datePickerHourSemanticsLabelOther => r'$hour 點';
@override
String get timerPickerHourLabelOne => r'小時';
String get datePickerMinuteSemanticsLabelOne => r'1 分鐘';
@override
String get timerPickerHourLabelOther => r'小時';
String get datePickerMinuteSemanticsLabelOther => r'$minute 分鐘';
@override
String get timerPickerMinuteLabelOne => r'分鐘';
String get pasteButtonLabel => r'貼上';
@override
String get timerPickerMinuteLabelOther => r'分鐘';
String get selectAllButtonLabel => r'全選';
@override
String get cutButtonLabel => r'剪下';
String get timerPickerHourLabelOne => r'小時';
@override
String get copyButtonLabel => r'複製';
String get timerPickerHourLabelOther => r'小時';
@override
String get pasteButtonLabel => r'貼上';
String get timerPickerMinuteLabelOne => r'分鐘';
@override
String get selectAllButtonLabel => r'全選';
String get timerPickerMinuteLabelOther => r'分鐘';
}
/// The translations for Chinese, as used in Hong Kong, using the Han script (`zh_Hant_HK`).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment