aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSARL ENR-68 <david@david.david>2013-09-26 18:11:52 +0200
committerSARL ENR-68 <david@david.david>2013-09-26 18:11:52 +0200
commitdc1e3e443117f8643906cdb8792404377a809624 (patch)
tree334bc64cbfb5e0eaca1f91615f29d3dcdb14f640 /tools
parent47e0f26f2232403458fd3c16f69b126fae0c5927 (diff)
downloadisodumper-dc1e3e443117f8643906cdb8792404377a809624.tar
isodumper-dc1e3e443117f8643906cdb8792404377a809624.tar.gz
isodumper-dc1e3e443117f8643906cdb8792404377a809624.tar.bz2
isodumper-dc1e3e443117f8643906cdb8792404377a809624.tar.xz
isodumper-dc1e3e443117f8643906cdb8792404377a809624.zip
add po-update.sh and po-compile.sh for translations
Diffstat (limited to 'tools')
-rw-r--r--tools/po-compile.sh17
-rwxr-xr-xtools/po-update.sh67
2 files changed, 84 insertions, 0 deletions
diff --git a/tools/po-compile.sh b/tools/po-compile.sh
new file mode 100644
index 0000000..2b4d364
--- /dev/null
+++ b/tools/po-compile.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -e
+
+cd "$(readlink -f "$(dirname "$0")/..")"
+
+find "$PWD/po" -type f -name '*.po' | \
+while read po_file; do
+ language="$(basename "$po_file")"
+ language="${language%.po}"
+ target="$PWD/po/$language/LC_MESSAGES/isodumper.mo"
+ /bin/mkdir --parents "$(dirname "$target")"
+ /usr/bin/msgfmt \
+ --check \
+ --output-file="$target" \
+ "$po_file"
+done
diff --git a/tools/po-update.sh b/tools/po-update.sh
new file mode 100755
index 0000000..27c2606
--- /dev/null
+++ b/tools/po-update.sh
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+if test -z "$1"; then
+ echo "Use: $0 <locale>"
+ exit 2
+fi
+LL_CC="$1"
+shift
+
+set -e
+
+cd "$(readlink -f "$(dirname "$0")/..")"
+
+VERSION=(0.1)
+DOMAIN=(isodumper)
+
+SOURCE_FILES=$(/bin/mktemp --tmpdir $DOMAIN-po-update-XXXXXX)
+find "lib" -name '*.py' >"$SOURCE_FILES"
+
+POT_DIR="$PWD/po"
+test -d "$POT_DIR"
+
+POT_FILE="$POT_DIR/$DOMAIN.pot"
+
+/usr/bin/xgettext \
+ --package-name "$DOMAIN" \
+ --package-version "$VERSION" \
+ --default-domain="$L_NAME" \
+ --language=Python --from-code=UTF-8 --files-from="$SOURCE_FILES" \
+ --no-escape --indent --add-location --sort-by-file \
+ --add-comments=I18N \
+ --output="$POT_FILE"
+
+/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"