summaryrefslogtreecommitdiff
path: root/build/tx-update
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2013-02-13 18:32:06 +0100
committerStef Walter <stefw@gnome.org>2013-02-13 18:32:44 +0100
commit726e98ed071601770c2724f358eabbbc682f1fdc (patch)
tree709a4634d70c6f5e226318bb5f50518a745ec6ee /build/tx-update
parent380f457ce458e32f1ccc15acfa664df82629981f (diff)
downloadp11-kit-726e98ed071601770c2724f358eabbbc682f1fdc.tar.gz
Pull translations from transifex
* Build a script to help with this https://bugs.freedesktop.org/show_bug.cgi?id=60792
Diffstat (limited to 'build/tx-update')
-rw-r--r--build/tx-update68
1 files changed, 68 insertions, 0 deletions
diff --git a/build/tx-update b/build/tx-update
new file mode 100644
index 0000000..55d771f
--- /dev/null
+++ b/build/tx-update
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+set -euf
+
+TX_PROJECT="p11-kit"
+TX_HOST="https://www.transifex.com"
+TX_RESOURCE="$TX_PROJECT.master"
+
+fail()
+{
+ echo "tx-update: $@" >&2
+ exit 2
+}
+
+tx_langs()
+(
+ cd .tx/$TX_RESOURCE
+ ls | sed 's/_translation//'
+)
+
+lingua_langs()
+{
+ cat po/LINGUAS | while read lang extra; do
+ case $lang in \
+ \#*) ;;
+ en) ;;
+ *) echo -n "$lang "
+ esac
+ done
+}
+
+if [ ! -d po ]; then
+ fail "run this script in the top level project directory"
+fi
+
+if [ ! -d .tx ]; then
+ tx init --host=$TX_HOST
+ tx set --source -r $TX_RESOURCE -l en po/$TX_PROJECT.pot
+fi
+
+# Push source to server
+tx push -s
+
+# Pull from the server
+tx pull -a
+
+pull_again="no"
+
+# Update LINGUAS
+for lang in $(tx_langs); do
+ if ! grep -qw $lang po/LINGUAS; then
+ echo $lang >> po/LINGUAS
+ pull_again="yes"
+ fi
+done
+
+# Setup associations
+for lang in $(lingua_langs); do
+ if [ ! -f "po/$lang.po" ]; then
+ tx set -r $TX_RESOURCE -l $lang po/$lang.po
+ pull_again="yes"
+ fi
+done
+
+# Pull and get all translations
+if [ "$pull_again" = "yes" ]; then
+ tx pull
+fi