Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/locales/locales_generator.sh
diff options
context:
space:
mode:
authorDaniel Girtler <blackrabbit256@gmail.com>2023-09-28 08:44:18 +1000
committerGitHub <noreply@github.com>2023-09-28 08:44:18 +1000
commit1e296b263714017596beeca27744a51c75f29504 (patch)
tree6b7fefcc5fccd62450911717f417db800ecf232e /archinstall/locales/locales_generator.sh
parent72856ed5ec869012c8d2ab0f1d17467653156556 (diff)
Fix 2118 (#2119)
* Update locales generation * Update README * Disable translation check --------- Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
Diffstat (limited to 'archinstall/locales/locales_generator.sh')
-rwxr-xr-xarchinstall/locales/locales_generator.sh43
1 files changed, 40 insertions, 3 deletions
diff --git a/archinstall/locales/locales_generator.sh b/archinstall/locales/locales_generator.sh
index cdd5be31..5386c3e6 100755
--- a/archinstall/locales/locales_generator.sh
+++ b/archinstall/locales/locales_generator.sh
@@ -2,11 +2,48 @@
cd $(dirname "$0")/..
-find . -type f -iname "*.py" | xargs xgettext --join-existing --no-location --omit-header -d base -o locales/base.pot
+function update_lang() {
+ file=$1
-for file in $(find locales/ -name "base.po"); do
echo "Updating: $file"
path=$(dirname $file)
msgmerge --quiet --no-location --width 512 --backup none --update $file locales/base.pot
msgfmt -o $path/base.mo $file
-done
+}
+
+
+function generate_all() {
+ for file in $(find locales/ -name "base.po"); do
+ update_lang "$file"
+ done
+}
+
+function generate_single_lang() {
+ lang_file="locales/$1/LC_MESSAGES/base.po"
+
+ if [ ! -f "$lang_file" ]; then
+ echo "Language files not found: $lang_file"
+ exit 1
+ fi
+
+ update_lang "$lang_file"
+}
+
+
+
+if [ $# -eq 0 ]
+ then
+ echo "Usage: locales_generator.sh <language_abbr>"
+ exit 1
+fi
+
+lang=$1
+
+# Update the base file containing all translatable string
+find . -type f -iname "*.py" | xargs xgettext --join-existing --no-location --omit-header -d base -o locales/base.pot
+
+case "$lang" in
+ "all") generate_all
+ ;;
+ *) generate_single_lang "$lang"
+esac