Skip to content

Commit 92c6116

Browse files
committed
Change language code region to ISO 3166-1-alpha-2 region code where needed
1 parent ce09eff commit 92c6116

File tree

6 files changed

+33
-22
lines changed

6 files changed

+33
-22
lines changed

app-k9mail/build.gradle.kts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ android {
4141
"de",
4242
"el",
4343
"en",
44-
"en_GB",
44+
"en-rGB",
4545
"eo",
4646
"es",
4747
"et",
@@ -66,8 +66,8 @@ android {
6666
"nl",
6767
"nn",
6868
"pl",
69-
"pt_BR",
70-
"pt_PT",
69+
"pt-rBR",
70+
"pt-rPT",
7171
"ro",
7272
"ru",
7373
"sk",
@@ -78,8 +78,8 @@ android {
7878
"tr",
7979
"uk",
8080
"vi",
81-
"zh_CN",
82-
"zh_TW",
81+
"zh-rCN",
82+
"zh-rTW",
8383
)
8484
}
8585

app-thunderbird/build.gradle.kts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ android {
4040
"de",
4141
"el",
4242
"en",
43-
"en_GB",
43+
"en-rGB",
4444
"eo",
4545
"es",
4646
"et",
@@ -65,8 +65,8 @@ android {
6565
"nl",
6666
"nn",
6767
"pl",
68-
"pt_BR",
69-
"pt_PT",
68+
"pt-rBR",
69+
"pt-rPT",
7070
"ro",
7171
"ru",
7272
"sl",
@@ -77,8 +77,8 @@ android {
7777
"tr",
7878
"uk",
7979
"vi",
80-
"zh_CN",
81-
"zh_TW",
80+
"zh-rCN",
81+
"zh-rTW",
8282
)
8383
}
8484

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package net.thunderbird.cli.translation
2+
3+
object AndroidLanguageCodeHelper {
4+
5+
/**
6+
* Fix the language code format to match the Android resource format.
7+
*/
8+
fun fixLanguageCodeFormat(languageCode: String): String {
9+
return if (languageCode.contains("-r")) languageCode.replace("-r", "_") else languageCode
10+
}
11+
}

cli/translation-cli/src/main/kotlin/net/thunderbird/cli/translation/LanguageCodeLoader.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ class LanguageCodeLoader(
2727
return languages.filter { it.translatedPercent >= threshold }
2828
.map {
2929
languageCodeLookup[it.code] ?: throw IllegalArgumentException("Language code ${it.code} is not mapped")
30-
}.map { fixLanguageCodeFormat(it) }
31-
.sorted()
32-
}
33-
34-
private fun fixLanguageCodeFormat(languageCode: String): String {
35-
return if (languageCode.contains("-r")) languageCode.replace("-r", "_") else languageCode
30+
}.sorted()
3631
}
3732
}

cli/translation-cli/src/main/kotlin/net/thunderbird/cli/translation/ResourceConfigurationsFormatter.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ package net.thunderbird.cli.translation
33
class ResourceConfigurationsFormatter {
44
fun format(languageCodes: List<String>) = buildString {
55
appendLine("android {")
6-
appendLine(" defaultConfig {")
7-
appendLine(" resourceConfigurations.addAll(")
8-
appendLine(" listOf(")
6+
appendLine(" androidResources {")
7+
appendLine(" // Keep in sync with the resource string array \"supported_languages\"")
8+
appendLine(" localeFilters += listOf(")
99
languageCodes.forEach { code ->
10-
appendLine(" \"$code\",")
10+
appendLine(" \"$code\",")
1111
}
12-
appendLine(" ),")
1312
appendLine(" )")
1413
appendLine(" }")
1514
appendLine("}")

cli/translation-cli/src/main/kotlin/net/thunderbird/cli/translation/TranslationCli.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,23 @@ class TranslationCli(
3333

3434
override fun run() {
3535
val languageCodes = languageCodeLoader.loadCurrentAndroidLanguageCodes(token, threshold)
36+
val androidLanguageCodes = languageCodes.map { AndroidLanguageCodeHelper.fixLanguageCodeFormat(it) }
3637
val size = languageCodes.size
3738

3839
echo("\nLanguages that are translated above the threshold of ($threshold%): $size")
3940
echo("--------------------------------------------------------------")
41+
echo("For androidResources.localeFilters:")
4042
echo(languageCodes.joinToString(", "))
43+
echo()
44+
echo("For array resource supported_languages:")
45+
echo(androidLanguageCodes.joinToString(", "))
4146
if (printAll) {
47+
echo()
4248
echo("--------------------------------------------------------------")
4349
echo(configurationsFormatter.format(languageCodes))
4450
echo("--------------------------------------------------------------")
4551
echo("--------------------------------------------------------------")
46-
echo(supportedLanguagesFormatter.format(languageCodes))
52+
echo(supportedLanguagesFormatter.format(androidLanguageCodes))
4753
echo("--------------------------------------------------------------")
4854
echo("Please read docs/translating.md for more information on how to update language values.")
4955
echo("--------------------------------------------------------------")

0 commit comments

Comments
 (0)