diff options
author | Jurijs Klopovskis <jurijs.klopovskis@zabbix.com> | 2022-04-20 17:21:57 +0300 |
---|---|---|
committer | Jurijs Klopovskis <jurijs.klopovskis@zabbix.com> | 2022-04-20 17:44:42 +0300 |
commit | bdf0ae94f2542c9ebb2fe7bca195177b2f5b32b7 (patch) | |
tree | 8804adb6780fefb87dfe0f35616c24e5c5f53619 /ui/locale/add_new_language.sh | |
parent | b526bcde6b2fcc929180e69abe34e81db4fc155b (diff) |
..F.I...S. [ZBXNEXT-7562] added en_GB locale
* commit 'a3237787cb310b5915a27ba7665797df3db2bf90':
.......... [ZBXNEXT-7562] fixed a typo
.D........ [ZBXNEXT-7562] updated ChangeLog entry
.D........ [ZBXNEXT-7562] added changelog file
..F....... [ZBXNEXT-7562] added en_GB locale
.......... [ZBXNEXT-7562] renamed en-GB locale directory to en_GB
.......... [ZBXNEXT-7562] removed DBpatch_5050032 and DBpatch_5050033
.......... [ZBXNEXT-7562] updated Project-Id-Version for en-GB locale
.......... [ZBXNEXT-7562] generated ui/locale/en-GB/LC_MESSAGES/frontend.po
.......... [ZBXNEXT-7562] updated ui/locale/add_new_language.sh script
cherry-picked from 44868ebb11865c2efc725484f1d7d89430c623a9
Diffstat (limited to 'ui/locale/add_new_language.sh')
-rwxr-xr-x | ui/locale/add_new_language.sh | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/ui/locale/add_new_language.sh b/ui/locale/add_new_language.sh index 29c9e346e90..9b20ef50bba 100755 --- a/ui/locale/add_new_language.sh +++ b/ui/locale/add_new_language.sh @@ -1,19 +1,30 @@ #!/bin/bash -messagetemplate=frontend.pot +function run +{ + local workdir=$(realpath $(dirname $0)) + local potfile=${workdir}/en/LC_MESSAGES/frontend.pot -[[ $1 ]] || { - echo "Specify language code" - exit 1 + [[ -n "$1" ]] || + die "specify language code!" + + local pofile=${workdir}/$1/LC_MESSAGES/frontend.po + [[ -f $pofile ]] && + die "$pofile already exists" + + if [[ -f $potfile ]]; then + mkdir -p $(dirname $pofile) + msginit --no-translator --no-wrap --locale=$1 --input=$potfile -o $pofile || die + git add $pofile || die + else + die "po template $potfile missing" + fi } -[ -f $messagetemplate ] && { - mkdir -p $1/LC_MESSAGES - msginit --no-translator --no-wrap --locale=$1 --input=frontend.pot \ - -o $1/LC_MESSAGES/frontend.po || exit 1 - echo "frontend.mo" >> $1/LC_MESSAGES/.gitignore - git add $1 -} || { - echo "po template $messagetemplate missing" +function die +{ + [[ -n "$@" ]] && >&2 echo -e "$@" exit 1 } + +run "$@" |