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
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user