aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/po-compile.sh35
-rwxr-xr-xtools/po-update.sh70
2 files changed, 105 insertions, 0 deletions
diff --git a/tools/po-compile.sh b/tools/po-compile.sh
new file mode 100644
index 0000000..a29d8cb
--- /dev/null
+++ b/tools/po-compile.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+set -e
+
+if test "$1" = "-h" -o "$1" = "--help"; then
+ echo "Use: $0 [<language>]"
+ echo "Run without arguments to compile all translation files."
+ exit 0
+fi
+
+cd "$(readlink -f "$(dirname "$0")/..")"
+
+update_mo(){
+ echo $1
+ language="$(basename "$1")"
+ language="${language%.po}"
+ target="$PWD/share/locale/$language/LC_MESSAGES/isodumper.mo"
+ echo $target
+ /bin/mkdir --parents "$(dirname "$target")"
+ /usr/bin/msgfmt \
+ --check \
+ --output-file="$target" \
+ "$1"
+}
+
+if test "$1"; then
+ for l in $(find "$PWD/po" -type f -name "$1.po"); do
+ echo $l
+ update_mo "$l"
+ done
+else
+ for l in $(find "$PWD/po" -type f -name '*.po'); do
+ update_mo "$l"
+ done
+fi \ No newline at end of file
diff --git a/tools/po-update.sh b/tools/po-update.sh
new file mode 100755
index 0000000..206ab86
--- /dev/null
+++ b/tools/po-update.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+
+set -e
+
+if test "$1" = "-h" -o "$1" = "--help"; then
+ echo "Use: $0 [<language>]"
+ echo "Run without arguments to update all translation files."
+ exit 0
+fi
+
+cd "$(readlink -f "$(dirname "$0")/..")"
+
+VERSION=(0.1)
+DOMAIN=(mageiasync)
+
+intltool-extract --type=gettext/ini share/applications/mageiasync.desktop.in
+
+POT_DIR="$PWD/po"
+test -d "$POT_DIR"
+
+POT_FILE="$POT_DIR/$DOMAIN.pot"
+
+/usr/bin/xgettext \
+ --package-name "$DOMAIN" \
+ --package-version "$VERSION" \
+ --language=Python --from-code=UTF-8 --keyword=_ --keyword=N_ \
+ --no-escape --add-location --sort-by-file \
+ --add-comments=I18N \
+ --output="$POT_FILE" \
+ mageiasync/mageiasync.py \
+ mageiasync/mageiaSyncDBprefs.py \
+ mageiasync/mageiaSyncDBprefs.py \
+ mageiasync/mageiaSyncDBrename.py \
+ mageiasync/mageiaSyncDBupdate.py \
+ mageiasync/mageiaSyncExt.py \
+ mageiasync/mageiaSyncUI.py \
+ mageiasync/mageiaSyncDBprefs.ui \
+ mageiasync/mageiaSyncDBrename.ui \
+ mageiasync/mageiaSyncDBupdate.ui \
+ mageiasync/mageiaSyncUI.ui \
+ share/applications/mageiasync.desktop.in.h
+
+/bin/sed --in-place --expression="s/charset=CHARSET/charset=UTF-8/" "$POT_FILE"
+
+intltool-merge --desktop-style po share/applications/mageiasync.desktop.in share/applications/mageiasync.desktop
+
+rm -f share/applications/mageiasync.desktop.in.h
+
+update_po() {
+ local LL_CC="$1"
+ local PO_FILE="$POT_DIR/$LL_CC.po"
+
+ echo "Update $(basename "$PO_FILE"):"
+ /usr/bin/msgmerge \
+ --update --no-fuzzy-matching \
+ --no-escape --add-location --sort-by-file \
+ --lang="$LL_CC" \
+ "$PO_FILE" "$POT_FILE"
+
+ # /bin/sed --in-place --expression="s/Language: \\\\n/Language: $L_NAME\\\\n/" "$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