From e48f5f4bb92bdf8774f9bc8f70fcc7ec0db6ab6a Mon Sep 17 00:00:00 2001 From: david_david Date: Sat, 28 Sep 2013 19:34:23 +0200 Subject: po-update.sh without arguments re-formats all translation files --- tools/po-update.sh | 91 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 40 deletions(-) (limited to 'tools') diff --git a/tools/po-update.sh b/tools/po-update.sh index 27c2606..bf468bc 100755 --- a/tools/po-update.sh +++ b/tools/po-update.sh @@ -1,21 +1,21 @@ #!/bin/sh -if test -z "$1"; then - echo "Use: $0 " - exit 2 -fi -LL_CC="$1" -shift - set -e +if test "$1" = "-h" -o "$1" = "--help"; then + echo "Use: $0 []" + echo "Run without arguments to update all translation files." + exit 0 +fi + cd "$(readlink -f "$(dirname "$0")/..")" -VERSION=(0.1) +#VERSION=(0.1) DOMAIN=(isodumper) SOURCE_FILES=$(/bin/mktemp --tmpdir $DOMAIN-po-update-XXXXXX) find "lib" -name '*.py' >"$SOURCE_FILES" +find "share/isodumper" -name '*.glade.h' >"$SOURCE_FILES" POT_DIR="$PWD/po" test -d "$POT_DIR" @@ -33,35 +33,46 @@ POT_FILE="$POT_DIR/$DOMAIN.pot" /bin/sed --in-place --expression="s/charset=CHARSET/charset=UTF-8/" "$POT_FILE" -PO_FILE="$POT_DIR/$LL_CC.po" - -test -r "$PO_FILE" || /usr/bin/msginit \ - --no-translator --locale="$LL_CC" \ - --input="$POT_FILE" \ - --output-file="$PO_FILE" - -#unfmt() { -# local SOURCE="/usr/share/locale/$LL_CC/LC_MESSAGES/$1.mo" -# if [ ! -f $SOURCE ] -# then -# local SOURCE="/usr/share/locale-langpack/$LL_CC/LC_MESSAGES/$1.mo" -# fi -# local TARGET="$(mktemp --tmpdir $1-$LL_CC-XXXXXX.po)" -# /usr/bin/msgunfmt \ -# --no-escape --indent \ -# --output-file="$TARGET" \ -# "$SOURCE" -# echo "$TARGET" -#} - -#/usr/bin/msgmerge \ -# --update --no-fuzzy-matching \ -# --no-escape --indent --add-location --sort-by-file \ -# --lang="$LL_CC" \ -# --compendium="$(unfmt gtk30)" \ -# --compendium="$(unfmt gtk30-properties)" \ -# "$PO_FILE" "$POT_FILE" - -# /bin/sed --in-place --expression="s/Language: \\\\n/Language: $L_NAME\\\\n/" "$PO_FILE" - -echo "Language file is $PO_FILE" + +unfmt() { + local SOURCE="/usr/share/locale/$LL_CC/LC_MESSAGES/$1.mo" + if test ! -f "$SOURCE"; then + SOURCE="/usr/share/locale-langpack/$LL_CC/LC_MESSAGES/$1.mo" + fi + local TARGET="$(mktemp --tmpdir $1-$LL_CC-XXXXXX.po)" + /usr/bin/msgunfmt \ + --no-escape --indent \ + --output-file="$TARGET" \ + "$SOURCE" + echo "$TARGET" +} + +update_po() { + local LL_CC="$1" + local PO_FILE="$POT_DIR/$LL_CC.po" + + test -r "$PO_FILE" || /usr/bin/msginit \ + --no-translator --locale="$LL_CC" \ + --input="$POT_FILE" \ + --output-file="$PO_FILE" + + /usr/bin/msgmerge \ + --update --no-fuzzy-matching \ + --no-escape --indent --add-location --sort-by-file \ + --lang="$LL_CC" \ + --compendium="$(unfmt gtk30)" \ + --compendium="$(unfmt gtk30-properties)" \ + "$PO_FILE" "$POT_FILE" + + # /bin/sed --in-place --expression="s/Language: \\\\n/Language: $L_NAME\\\\n/" "$PO_FILE" + echo "Updated $PO_FILE" +} + +if test "$1"; then + update_po "$1" +else + for l in $(ls -1 "$POT_DIR"/??.po); do + l="$(basename "$l")" + update_po "${l%.po}" + done +fi -- cgit v1.2.1