Cw 577 translation fixes (#1290)

* pt.1

* alphabetize

* alphabetize translation files

* revert trailing comma addition

* fix translations
This commit is contained in:
Matthew Fosse 2024-02-06 12:12:51 -08:00 committed by GitHub
parent 39a73b2058
commit 3945a3d7b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 19385 additions and 19329 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -13,10 +13,20 @@ void main(List<String> args) async {
print('Appending "$name": "$text"'); print('Appending "$name": "$text"');
// add translation to all languages:
for (var lang in langs) { for (var lang in langs) {
final fileName = getArbFileName(lang); final fileName = getArbFileName(lang);
final translation = await getTranslation(text, lang); final translation = await getTranslation(text, lang);
appendStringToArbFile(fileName, name, translation); appendStringToArbFile(fileName, name, translation);
} }
print('Alphabetizing all files...');
for (var lang in langs) {
final fileName = getArbFileName(lang);
alphabetizeArbFile(fileName);
}
print('Done!');
} }

View file

@ -47,9 +47,7 @@ Map<String, dynamic> readArbFile(File file) {
} }
String getArbFileName(String lang) { String getArbFileName(String lang) {
final shortLang = lang final shortLang = lang.split("-").first;
.split("-")
.first;
return "./res/values/strings_$shortLang.arb"; return "./res/values/strings_$shortLang.arb";
} }
@ -66,3 +64,25 @@ List<String> getMissingKeysInArbFile(String fileName, Iterable<String> langKeys)
return results; return results;
} }
void alphabetizeArbFile(String fileName) {
final file = File(fileName);
final arbObj = readArbFile(file);
final sortedKeys = arbObj.keys.toList()
..sort((a, b) => a.toLowerCase().compareTo(b.toLowerCase()));
final Map<String, dynamic> sortedArbObj = {};
for (var key in sortedKeys) {
sortedArbObj[key] = arbObj[key];
}
final outputContent = json
.encode(sortedArbObj)
.replaceAll('","', '",\n "')
.replaceAll('{"', '{\n "')
.replaceAll('"}', '"\n}')
.replaceAll('":"', '": "')
.replaceAll('\$ {', '\${');
file.writeAsStringSync(outputContent);
}