Add Explicit list of supported languages, generated from Localazy data.
This commit is contained in:
parent
474a1412ed
commit
c64fb6f510
6 changed files with 119 additions and 4 deletions
1
.github/workflows/sync-localazy.yml
vendored
1
.github/workflows/sync-localazy.yml
vendored
|
|
@ -33,6 +33,7 @@ jobs:
|
||||||
- name: Run Localazy script
|
- name: Run Localazy script
|
||||||
run: |
|
run: |
|
||||||
./tools/localazy/downloadStrings.sh --all
|
./tools/localazy/downloadStrings.sh --all
|
||||||
|
./tools/localazy/importSupportedLocalesFromLocalazy.py
|
||||||
./tools/test/generateAllScreenshots.py
|
./tools/test/generateAllScreenshots.py
|
||||||
- name: Create Pull Request for Strings
|
- name: Create Pull Request for Strings
|
||||||
uses: peter-evans/create-pull-request@v6
|
uses: peter-evans/create-pull-request@v6
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import extension.allServicesImpl
|
||||||
import extension.gitBranchName
|
import extension.gitBranchName
|
||||||
import extension.gitRevision
|
import extension.gitRevision
|
||||||
import extension.koverDependencies
|
import extension.koverDependencies
|
||||||
|
import extension.locales
|
||||||
import extension.setupKover
|
import extension.setupKover
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
|
|
@ -74,6 +75,10 @@ android {
|
||||||
isUniversalApk = true
|
isUniversalApk = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
resourceConfigurations += locales
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
|
@ -165,10 +170,6 @@ android {
|
||||||
buildConfigField("String", "FLAVOR_DESCRIPTION", "\"FDroid\"")
|
buildConfigField("String", "FLAVOR_DESCRIPTION", "\"FDroid\"")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
androidResources {
|
|
||||||
generateLocaleConfig = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
androidComponents {
|
androidComponents {
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
android:fullBackupContent="@xml/backup_rules"
|
android:fullBackupContent="@xml/backup_rules"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
|
android:localeConfig="@xml/locales_config"
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
|
|
|
||||||
19
app/src/main/res/xml/locales_config.xml
Normal file
19
app/src/main/res/xml/locales_config.xml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
<!-- File generated by importSupportedLocalesFromLocalazy.py, do not edit -->
|
||||||
|
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<locale android:name="be"/>
|
||||||
|
<locale android:name="bg"/>
|
||||||
|
<locale android:name="cs"/>
|
||||||
|
<locale android:name="de"/>
|
||||||
|
<locale android:name="en"/>
|
||||||
|
<locale android:name="es"/>
|
||||||
|
<locale android:name="fr"/>
|
||||||
|
<locale android:name="hu"/>
|
||||||
|
<locale android:name="in"/>
|
||||||
|
<locale android:name="it"/>
|
||||||
|
<locale android:name="ro"/>
|
||||||
|
<locale android:name="ru"/>
|
||||||
|
<locale android:name="sk"/>
|
||||||
|
<locale android:name="sv"/>
|
||||||
|
<locale android:name="uk"/>
|
||||||
|
<locale android:name="zh-TW"/>
|
||||||
|
</locale-config>
|
||||||
22
plugins/src/main/kotlin/extension/locales.kt
Normal file
22
plugins/src/main/kotlin/extension/locales.kt
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
// File generated by importSupportedLocalesFromLocalazy.py, do not edit
|
||||||
|
|
||||||
|
package extension
|
||||||
|
|
||||||
|
val locales = setOf(
|
||||||
|
"be",
|
||||||
|
"bg",
|
||||||
|
"cs",
|
||||||
|
"de",
|
||||||
|
"en",
|
||||||
|
"es",
|
||||||
|
"fr",
|
||||||
|
"hu",
|
||||||
|
"in",
|
||||||
|
"it",
|
||||||
|
"ro",
|
||||||
|
"ru",
|
||||||
|
"sk",
|
||||||
|
"sv",
|
||||||
|
"uk",
|
||||||
|
"zh-rTW",
|
||||||
|
)
|
||||||
71
tools/localazy/importSupportedLocalesFromLocalazy.py
Executable file
71
tools/localazy/importSupportedLocalesFromLocalazy.py
Executable file
|
|
@ -0,0 +1,71 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
def getLocalesFromLocalazy():
|
||||||
|
command = subprocess.run(
|
||||||
|
["localazy languages --read-key a7876306080832595063-aa37154bb3772f6146890fca868d155b2228b492c56c91f67abdcdfb74d6142d --csv"],
|
||||||
|
shell=True,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
data = command.stdout
|
||||||
|
result = []
|
||||||
|
for line in data.split("\n"):
|
||||||
|
if line:
|
||||||
|
line = line.split(",")
|
||||||
|
if (line[6] == "true"):
|
||||||
|
result.append(line[0])
|
||||||
|
return sorted(result)
|
||||||
|
|
||||||
|
|
||||||
|
def normalizeForResourceConfigurations(locale):
|
||||||
|
match locale:
|
||||||
|
case "id":
|
||||||
|
return "in"
|
||||||
|
case "zh_TW#Hant":
|
||||||
|
return "zh-rTW"
|
||||||
|
case _:
|
||||||
|
return locale
|
||||||
|
|
||||||
|
|
||||||
|
def normalizeForLocalConfig(locale):
|
||||||
|
match locale:
|
||||||
|
case "id":
|
||||||
|
return "in"
|
||||||
|
case "zh_TW#Hant":
|
||||||
|
return "zh-TW"
|
||||||
|
case _:
|
||||||
|
return locale
|
||||||
|
|
||||||
|
|
||||||
|
def generateLocaleFile(locales, file):
|
||||||
|
with open("plugins/src/main/kotlin/extension/locales.kt", "w") as f:
|
||||||
|
f.write("// File generated by " + file + ", do not edit\n\n")
|
||||||
|
f.write("package extension\n\n")
|
||||||
|
f.write("val locales = setOf(\n")
|
||||||
|
for locale in locales:
|
||||||
|
f.write(" \"" + normalizeForResourceConfigurations(locale) + "\",\n")
|
||||||
|
f.write(")\n")
|
||||||
|
|
||||||
|
|
||||||
|
def generateLocalesConfigFile(locales, file):
|
||||||
|
with open("app/src/main/res/xml/locales_config.xml", "w") as f:
|
||||||
|
f.write("<!-- File generated by " + file + ", do not edit -->\n")
|
||||||
|
f.write('<locale-config xmlns:android="http://schemas.android.com/apk/res/android">\n')
|
||||||
|
for locale in locales:
|
||||||
|
f.write(" <locale android:name=\"" + normalizeForLocalConfig(locale) + "\"/>\n")
|
||||||
|
f.write("</locale-config>\n")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
file = os.path.basename(__file__)
|
||||||
|
locales = getLocalesFromLocalazy()
|
||||||
|
generateLocaleFile(locales, file)
|
||||||
|
generateLocalesConfigFile(locales, file)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue