mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
refactor: improve locale parsing and normalization in localization ge… (#3330)
* refactor: improve locale parsing and normalization in localization generation script * Remove chinese tranditional because it's breaking flutter * delete retry in case of parallel save [skip ci] * Improve translation
This commit is contained in:
@@ -51,12 +51,19 @@ Future<void> main(List<String> args) async {
|
||||
|
||||
final localePath = <String, dynamic>{};
|
||||
await dir.list(recursive: false).forEach((element) {
|
||||
try {
|
||||
final shortLocale = element.path.split('_',)[1].split('.')[0];
|
||||
localePath[shortLocale] = element.path;
|
||||
} catch (e) {
|
||||
// Parse the locale from the file name (e.g. strings_pt_br.arb -> pt_BR),
|
||||
// normalizing the case so keys match LanguageService.supportedLocales.
|
||||
final fileName = element.uri.pathSegments.last;
|
||||
if (!fileName.startsWith('strings_') || !fileName.endsWith('.arb')) {
|
||||
printV('Wrong file: ${element.path}');
|
||||
return;
|
||||
}
|
||||
final parts =
|
||||
fileName.substring('strings_'.length, fileName.length - '.arb'.length).split('_');
|
||||
final locale = parts.length > 1
|
||||
? '${parts.first.toLowerCase()}_${parts.sublist(1).join('_').toUpperCase()}'
|
||||
: parts.first.toLowerCase();
|
||||
localePath[locale] = element.path;
|
||||
});
|
||||
|
||||
if (!localePath.keys.contains(defaultLocale)) {
|
||||
|
||||
@@ -2,5 +2,5 @@ const defaultLang = "en";
|
||||
const langs = [
|
||||
"ar", "bg", "cs", "de", "en", "es", "fa", "fr", "gn", "ha", "hi", "hr", "hy", "id", "it",
|
||||
"ja", "ko", "my", "nl", "pl", "pt", "ru", "th", "tl", "tr", "uk", "ur", "yo",
|
||||
"vi", "zh-cn", "zh-tw" // zh-cn for Chinese (Simplified), zh-tw for Chinese (Traditional)
|
||||
"vi", "zh-cn" // zh-cn for Chinese (Simplified)
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user