Sort locales and method/properties/getters alphabetically (#44761)

* Sort locales and method/properties/getters alphabetically

* Refresh stocks example to show proper sorting
This commit is contained in:
Shi-Hao Hong
2019-11-13 10:14:53 -08:00
committed by GitHub
parent f766871eb9
commit 0d348138aa
3 changed files with 22 additions and 18 deletions

View File

@@ -149,6 +149,10 @@ const String pluralMethodTemplate = '''
}
''';
int sortFilesByPath (FileSystemEntity a, FileSystemEntity b) {
return a.path.compareTo(b.path);
}
List<String> genMethodParameters(Map<String, dynamic> bundle, String key, String type) {
final Map<String, dynamic> attributesMap = bundle['@$key'];
if (attributesMap != null && attributesMap.containsKey('placeholders')) {
@@ -384,7 +388,7 @@ Future<void> main(List<String> arguments) async {
final Set<String> supportedLanguageCodes = <String>{};
final Set<LocaleInfo> supportedLocales = <LocaleInfo>{};
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<void> main(List<String> 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))