From b9f380a2b864d056be653709077286d72376f715 Mon Sep 17 00:00:00 2001 From: FC Stegerman Date: Tue, 5 Sep 2023 02:16:55 +0200 Subject: [PATCH 1/7] s/zh-TW/zh-rTW/ --- app/src/main/res/values/settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index 9e28c7878..2802d0b60 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -100,7 +100,7 @@ sv tr uk - zh-TW + zh-rTW zh-rCN From 025be0e5e3526a08e223d07ec5b66b33ceed94b0 Mon Sep 17 00:00:00 2001 From: FC Stegerman Date: Tue, 5 Sep 2023 02:17:20 +0200 Subject: [PATCH 2/7] add & use .scripts/locales.py for localeConfig --- .scripts/locales.py | 36 ++++++++++++++++++++ app/build.gradle | 7 ++-- app/src/main/AndroidManifest.xml | 5 +-- app/src/main/res/xml/locales_config.xml | 45 +++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 7 deletions(-) create mode 100755 .scripts/locales.py create mode 100644 app/src/main/res/xml/locales_config.xml diff --git a/.scripts/locales.py b/.scripts/locales.py new file mode 100755 index 000000000..6d2443047 --- /dev/null +++ b/.scripts/locales.py @@ -0,0 +1,36 @@ +#!/usr/bin/python3 + +import subprocess +import xml.etree.ElementTree as ET + +root = ET.parse("app/src/main/res/values/settings.xml").getroot() +for e in root.findall("string-array"): + if e.get("name") == "locale_values": + locales = [x.text for x in e if x.text] + break + +locales = [ + # e.g. de or es-rAR (not es-AR) + loc.replace("-", "-r") if "-" in loc and loc[loc.index("-") + 1] != "r" else loc + for loc in locales +] + +res = ", ".join(f'"{loc}"' for loc in locales) +sed = [ + "sed", + "-i", + f"s/resourceConfigurations .*/resourceConfigurations += [{res}]/", + "app/build.gradle" +] +subprocess.run(sed, check=True) + +with open("app/src/main/res/xml/locales_config.xml", "w") as fh: + fh.write('\n') + fh.write('\n') + fh.write(' \n') + for loc in locales: + if loc != "en": + # e.g. de or en-AR (not es-rAR) + loc = loc.replace("-r", "-") + fh.write(f' \n') + fh.write('\n') diff --git a/app/build.gradle b/app/build.gradle index 1758fc5dd..daa04ec98 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,6 +24,8 @@ android { vectorDrawables.useSupportLibrary true multiDexEnabled true + + resourceConfigurations += ["ar", "bg", "bn", "bn-rIN", "bs", "ca", "cs", "cy", "da", "de", "el-rGR", "en", "eo", "es", "es-rAR", "fi", "fr", "he-rIL", "hi", "hr", "hu", "in-rID", "is", "it", "ja", "ko", "lt", "lv", "nb-rNO", "nl", "oc", "pl", "pt", "ro-rRO", "ru", "sk", "sl", "sv", "tr", "uk", "zh-rTW", "zh-rCN"] } buildTypes { @@ -81,11 +83,6 @@ android { lintConfig file('lint.xml') } namespace 'protect.card_locker' - - androidResources { - generateLocaleConfig true - } - } dependencies { diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8680c5c49..f4b44180f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -27,7 +27,8 @@ android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" - android:theme="@style/AppTheme"> + android:theme="@style/AppTheme" + android:localeConfig="@xml/locales_config"> - \ No newline at end of file + diff --git a/app/src/main/res/xml/locales_config.xml b/app/src/main/res/xml/locales_config.xml new file mode 100644 index 000000000..01c186d52 --- /dev/null +++ b/app/src/main/res/xml/locales_config.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e8c2e6ecd09b390ff192d3f4d9c92e97e217a6cc Mon Sep 17 00:00:00 2001 From: FC Stegerman Date: Tue, 5 Sep 2023 02:42:30 +0200 Subject: [PATCH 3/7] add all langs & rm empty ones --- app/build.gradle | 2 +- app/src/main/res/values-ars/strings.xml | 2 -- app/src/main/res/values-enm/strings.xml | 2 -- app/src/main/res/values-lzh/strings.xml | 2 -- app/src/main/res/values/settings.xml | 2 ++ app/src/main/res/xml/locales_config.xml | 2 ++ 6 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 app/src/main/res/values-ars/strings.xml delete mode 100644 app/src/main/res/values-enm/strings.xml delete mode 100644 app/src/main/res/values-lzh/strings.xml diff --git a/app/build.gradle b/app/build.gradle index daa04ec98..759e0d899 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,7 +25,7 @@ android { vectorDrawables.useSupportLibrary true multiDexEnabled true - resourceConfigurations += ["ar", "bg", "bn", "bn-rIN", "bs", "ca", "cs", "cy", "da", "de", "el-rGR", "en", "eo", "es", "es-rAR", "fi", "fr", "he-rIL", "hi", "hr", "hu", "in-rID", "is", "it", "ja", "ko", "lt", "lv", "nb-rNO", "nl", "oc", "pl", "pt", "ro-rRO", "ru", "sk", "sl", "sv", "tr", "uk", "zh-rTW", "zh-rCN"] + resourceConfigurations += ["ar", "ast", "bg", "bn", "bn-rIN", "bs", "ca", "cs", "cy", "da", "de", "el-rGR", "en", "eo", "es", "es-rAR", "fi", "fr", "he-rIL", "hi", "hr", "hu", "in-rID", "is", "it", "ja", "ko", "lb", "lt", "lv", "nb-rNO", "nl", "oc", "pl", "pt", "ro-rRO", "ru", "sk", "sl", "sv", "tr", "uk", "zh-rTW", "zh-rCN"] } buildTypes { diff --git a/app/src/main/res/values-ars/strings.xml b/app/src/main/res/values-ars/strings.xml deleted file mode 100644 index a6b3daec9..000000000 --- a/app/src/main/res/values-ars/strings.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/values-enm/strings.xml b/app/src/main/res/values-enm/strings.xml deleted file mode 100644 index a6b3daec9..000000000 --- a/app/src/main/res/values-enm/strings.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/values-lzh/strings.xml b/app/src/main/res/values-lzh/strings.xml deleted file mode 100644 index a6b3daec9..000000000 --- a/app/src/main/res/values-lzh/strings.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index 2802d0b60..7f9402eb5 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -61,6 +61,7 @@ ar + ast bg bn bn-rIN @@ -86,6 +87,7 @@ it ja ko + lb lt lv nb-rNO diff --git a/app/src/main/res/xml/locales_config.xml b/app/src/main/res/xml/locales_config.xml index 01c186d52..81e05ad03 100644 --- a/app/src/main/res/xml/locales_config.xml +++ b/app/src/main/res/xml/locales_config.xml @@ -2,6 +2,7 @@ + @@ -26,6 +27,7 @@ + From 30f2eb1fb954163838a2052da2732a5431dde3c3 Mon Sep 17 00:00:00 2001 From: FC Stegerman Date: Tue, 5 Sep 2023 02:46:45 +0200 Subject: [PATCH 4/7] CI: add update-locales workflow --- .github/workflows/update-locales.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/update-locales.yml diff --git a/.github/workflows/update-locales.yml b/.github/workflows/update-locales.yml new file mode 100644 index 000000000..20786cbb9 --- /dev/null +++ b/.github/workflows/update-locales.yml @@ -0,0 +1,20 @@ +name: Update locales +on: + push: + branches: + - main + paths: + - app/src/main/res/values/settings.xml +jobs: + update-locales: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Update locales + run: .scripts/locales.py + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + title: "Update locales" + commit-message: "Update locales" + branch-suffix: timestamp From f025d72a11e503b4d2539d22d2498abe3c3fc99d Mon Sep 17 00:00:00 2001 From: FC Stegerman Date: Tue, 5 Sep 2023 02:49:13 +0200 Subject: [PATCH 5/7] add comment about locales to settings.xml --- app/src/main/res/values/settings.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index 7f9402eb5..b1f2073d7 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -58,6 +58,11 @@ @string/settings_brown_theme + ar From 1367e29bd48e4eb4341183135c1ebd8ba91b9481 Mon Sep 17 00:00:00 2001 From: FC Stegerman Date: Tue, 5 Sep 2023 02:56:38 +0200 Subject: [PATCH 6/7] disable languages < 29% translated --- app/build.gradle | 2 +- app/src/main/res/values/settings.xml | 4 ++-- app/src/main/res/xml/locales_config.xml | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 759e0d899..deec927db 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,7 +25,7 @@ android { vectorDrawables.useSupportLibrary true multiDexEnabled true - resourceConfigurations += ["ar", "ast", "bg", "bn", "bn-rIN", "bs", "ca", "cs", "cy", "da", "de", "el-rGR", "en", "eo", "es", "es-rAR", "fi", "fr", "he-rIL", "hi", "hr", "hu", "in-rID", "is", "it", "ja", "ko", "lb", "lt", "lv", "nb-rNO", "nl", "oc", "pl", "pt", "ro-rRO", "ru", "sk", "sl", "sv", "tr", "uk", "zh-rTW", "zh-rCN"] + resourceConfigurations += ["ar", "ast", "bg", "bn", "bn-rIN", "bs", "cs", "da", "de", "el-rGR", "en", "eo", "es", "es-rAR", "fi", "fr", "he-rIL", "hi", "hr", "hu", "in-rID", "is", "it", "ja", "ko", "lb", "lt", "lv", "nb-rNO", "nl", "oc", "pl", "pt", "ro-rRO", "ru", "sk", "sl", "sv", "tr", "uk", "zh-rTW", "zh-rCN"] } buildTypes { diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index b1f2073d7..b20815fef 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -71,9 +71,9 @@ bn bn-rIN bs - ca + cs - cy + da de el-rGR diff --git a/app/src/main/res/xml/locales_config.xml b/app/src/main/res/xml/locales_config.xml index 81e05ad03..4778d5d16 100644 --- a/app/src/main/res/xml/locales_config.xml +++ b/app/src/main/res/xml/locales_config.xml @@ -7,9 +7,7 @@ - - From 704a420e5ee0c7342ae4f01f0f2e09c9003848d1 Mon Sep 17 00:00:00 2001 From: FC Stegerman Date: Thu, 7 Sep 2023 23:39:19 +0200 Subject: [PATCH 7/7] disable ast & lb again --- app/build.gradle | 2 +- app/src/main/res/values/settings.xml | 4 ++-- app/src/main/res/xml/locales_config.xml | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index deec927db..cd3efa0ea 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,7 +25,7 @@ android { vectorDrawables.useSupportLibrary true multiDexEnabled true - resourceConfigurations += ["ar", "ast", "bg", "bn", "bn-rIN", "bs", "cs", "da", "de", "el-rGR", "en", "eo", "es", "es-rAR", "fi", "fr", "he-rIL", "hi", "hr", "hu", "in-rID", "is", "it", "ja", "ko", "lb", "lt", "lv", "nb-rNO", "nl", "oc", "pl", "pt", "ro-rRO", "ru", "sk", "sl", "sv", "tr", "uk", "zh-rTW", "zh-rCN"] + resourceConfigurations += ["ar", "bg", "bn", "bn-rIN", "bs", "cs", "da", "de", "el-rGR", "en", "eo", "es", "es-rAR", "fi", "fr", "he-rIL", "hi", "hr", "hu", "in-rID", "is", "it", "ja", "ko", "lt", "lv", "nb-rNO", "nl", "oc", "pl", "pt", "ro-rRO", "ru", "sk", "sl", "sv", "tr", "uk", "zh-rTW", "zh-rCN"] } buildTypes { diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index b20815fef..e187197a7 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -66,7 +66,7 @@ ar - ast + bg bn bn-rIN @@ -92,7 +92,7 @@ it ja ko - lb + lt lv nb-rNO diff --git a/app/src/main/res/xml/locales_config.xml b/app/src/main/res/xml/locales_config.xml index 4778d5d16..97ae032eb 100644 --- a/app/src/main/res/xml/locales_config.xml +++ b/app/src/main/res/xml/locales_config.xml @@ -2,7 +2,6 @@ - @@ -25,7 +24,6 @@ -