From d5a33da0a38653ce47b166715ccce859f99ac6c9 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Tue, 9 Jul 2013 11:57:09 +0200 Subject: [PATCH] Added pulltx / pushtx to i18n.sh --- i18n.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/i18n.sh b/i18n.sh index f18a4ae..60669a6 100755 --- a/i18n.sh +++ b/i18n.sh @@ -1,14 +1,32 @@ #!/bin/bash -# Make sure `django-admin.py` is available +### Helper functions -hash django-admin.py 2>/dev/null || - { echo >&2 "django-admin.py not found. Please install Django."; exit 1; } +function assert_django { + hash django-admin.py 2>/dev/null || + { echo >&2 "django-admin.py not found. Please install Django."; exit 1; } +} + +function assert_tx { + hash tx 2>/dev/null || + { echo >&2 "tx not found. Please install transifex-client."; exit 1; } +} + +function are_you_sure { + read -r -p "$1 Are you sure? [y/n] " response + if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]] + then + : + else + exit 1 + fi +} -# Functions +### Command functions -function makemessages() { +function makemessages { + assert_django echo "### Processing djadmin2..." ( cd djadmin2; django-admin.py makemessages -a ) echo "### Processing example app..." @@ -17,7 +35,8 @@ function makemessages() { ( cd example2/polls; django-admin.py makemessages -a ) } -function compilemessages() { +function compilemessages { + assert_django echo "### Processing djadmin2..." ( cd djadmin2; django-admin.py compilemessages ) echo "### Processing example app..." @@ -26,14 +45,29 @@ function compilemessages() { ( cd example2/polls; django-admin.py compilemessages ) } +function pulltx { + assert_tx + echo "### Pulling new translations from Transifex..." + tx pull -a +} -# Parse arguments +function pushtx { + assert_tx + are_you_sure "Warning: This might destroy existing translations." + echo "### Pushing translations and sources to Transifex..." + tx push -s +} + + +### Parse arguments case $1 in "") echo "Available commands:" - echo "--- makemessages" - echo "--- compilemessages"; + echo "--- makemessages: Generate or update .po files" + echo "--- compilemessages: Compile .po files to .mo files"; + echo "--- pulltx: Pull new translations from Transifex"; + echo "--- pushtx: Push translations and sources to Transifex"; ;; "makemessages") makemessages @@ -41,4 +75,13 @@ case $1 in "compilemessages") compilemessages ;; + "pulltx") + pulltx + ;; + "pushtx") + pushtx + ;; + *) + echo "Unknown command: $1" + ;; esac