From 1e296b263714017596beeca27744a51c75f29504 Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Thu, 28 Sep 2023 08:44:18 +1000 Subject: Fix 2118 (#2119) * Update locales generation * Update README * Disable translation check --------- Co-authored-by: Daniel Girtler --- archinstall/locales/locales_generator.sh | 43 +++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'archinstall/locales/locales_generator.sh') 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 " + 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 -- cgit v1.2.3-70-g09d2 From 7011ac095f7a9e1b136579e7999d28e50a0e2b1c Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 16 Apr 2024 11:05:50 +0200 Subject: Fix up locale generator to exit on error instead of ignoring it, handle filenames better (#2422) Don't mix tabs and spaces, use tabs, just like the main script --- archinstall/locales/locales_generator.sh | 51 ++++++++++++++++---------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'archinstall/locales/locales_generator.sh') diff --git a/archinstall/locales/locales_generator.sh b/archinstall/locales/locales_generator.sh index 5386c3e6..80e3bd03 100755 --- a/archinstall/locales/locales_generator.sh +++ b/archinstall/locales/locales_generator.sh @@ -1,49 +1,48 @@ -#!/bin/bash +#!/usr/bin/env bash +set -euo pipefail cd $(dirname "$0")/.. function update_lang() { - file=$1 + file=${1} - 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 + 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}" } function generate_all() { - for file in $(find locales/ -name "base.po"); do - update_lang "$file" - done + 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" + lang_file="locales/${1}/LC_MESSAGES/base.po" - if [ ! -f "$lang_file" ]; then - echo "Language files not found: $lang_file" - exit 1 - fi + if [ ! -f "${lang_file}" ]; then + echo "Language files not found: ${lang_file}" + exit 1 + fi - update_lang "$lang_file" + update_lang "${lang_file}" } - -if [ $# -eq 0 ] - then - echo "Usage: locales_generator.sh " - exit 1 +if [ $# -eq 0 ]; then + echo "Usage: ${0} " + echo "Special case 'all' for builds all languages." + exit 1 fi -lang=$1 +lang=${1} -# Update the base file containing all translatable string +# Update the base file containing all translatable strings 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" +case "${lang}" in + "all") generate_all;; + *) generate_single_lang "${lang}" esac -- cgit v1.2.3-70-g09d2