index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
author | Andreas Baumann <mail@andreasbaumann.cc> | 2024-05-10 15:56:28 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2024-05-10 15:56:28 +0200 |
commit | 683da22298abbd90f51d4dd38a7ec4b0dfb04555 (patch) | |
tree | ec2ac04967f9277df038edc362201937b331abe5 /archinstall/locales/locales_generator.sh | |
parent | af7ab9833c9f9944874f0162ae0975175ddc628d (diff) | |
parent | 3381cd55673e5105697d354cf4a1be9a7bcef062 (diff) |
-rwxr-xr-x | archinstall/locales/locales_generator.sh | 50 |
diff --git a/archinstall/locales/locales_generator.sh b/archinstall/locales/locales_generator.sh index cdd5be31..80e3bd03 100755 --- a/archinstall/locales/locales_generator.sh +++ b/archinstall/locales/locales_generator.sh @@ -1,12 +1,48 @@ -#!/bin/bash +#!/usr/bin/env bash +set -euo pipefail cd $(dirname "$0")/.. +function update_lang() { + 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}" +} + + +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: ${0} <language_abbr>" + echo "Special case 'all' for <language_abbr> builds all languages." + exit 1 +fi + +lang=${1} + +# 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 -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 +case "${lang}" in + "all") generate_all;; + *) generate_single_lang "${lang}" +esac |