Add gen_l10n sorting tests (#46247)

* Add tests for sorting arbPathString, supportedLocales and supportedLanguageCodes alphabetically

* Plural arbPathStrings

* Factor out singleZhMessageArbFileString

* Make translations more accurate and generic
This commit is contained in:
Shi-Hao Hong
2019-12-13 10:03:56 -08:00
committed by GitHub
parent 6a5ef29a75
commit 2eed59c1d5
3 changed files with 84 additions and 14 deletions

View File

@@ -92,7 +92,7 @@ Future<void> main(List<String> arguments) async {
'--output-dir=${localizationsGenerator.l10nDirectory.path}',
'--no-use-deferred-loading',
localizationsGenerator.outputFile.path,
...localizationsGenerator.arbFilenames,
...localizationsGenerator.arbPathStrings,
]);
if (generateFromArbResult.exitCode != 0) {
stderr.write(generateFromArbResult.stderr);

View File

@@ -359,8 +359,8 @@ class LocalizationsGenerator {
/// Sets the [className] for the localizations and localizations delegate
/// classes.
/// The list of all arb files in [l10nDirectory].
final List<String> arbFilenames = <String>[];
/// The list of all arb path strings in [l10nDirectory].
final List<String> arbPathStrings = <String>[];
/// The supported language codes as found in the arb files located in
/// [l10nDirectory].
@@ -477,7 +477,7 @@ class LocalizationsGenerator {
localeString = arbFilenameLocaleRE.firstMatch(filePath)[1];
}
arbFilenames.add(filePath);
arbPathStrings.add(filePath);
final LocaleInfo localeInfo = LocaleInfo.fromString(localeString);
if (localeInfoList.contains(localeInfo))
throw L10nException(
@@ -488,6 +488,7 @@ class LocalizationsGenerator {
}
}
arbPathStrings.sort();
localeInfoList.sort();
supportedLocales.addAll(localeInfoList);
supportedLanguageCodes.addAll(localeInfoList.map((LocaleInfo localeInfo) {