summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-ximport-translations47
1 files changed, 36 insertions, 11 deletions
diff --git a/import-translations b/import-translations
index 3791b01..51f2893 100755
--- a/import-translations
+++ b/import-translations
@@ -5,35 +5,58 @@ set -u
EXCLUDE_LANGS='fr pt_BR'
TAILS_PO_DIR='po'
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
TOR_TRANSLATION_REMOTE='https://git.torproject.org/translation.git'
-TOR_TRANSLATION_DIR='tmp/tor-translation'
+TOR_TRANSLATION_DIR="$SCRIPT_DIR/tmp/tor-translation"
GIT_IN_TOR_TRANSLATION_DIR="git \
- --work-tree=$TOR_TRANSLATION_DIR \
- --git-dir=$TOR_TRANSLATION_DIR/.git"
+ --work-tree=\"$TOR_TRANSLATION_DIR\" \
+ --git-dir=\"$TOR_TRANSLATION_DIR/.git\""
### External libraries
-. config/chroot_local-includes/usr/local/lib/tails-shell-library/po.sh
+. "$SCRIPT_DIR/config/chroot_local-includes/usr/local/lib/tails-shell-library/po.sh"
lang_is_excluded () {
local lang="$1"
echo -n "$EXCLUDE_LANGS" | grep -qs -w "$lang"
}
+# Detect which project is in current folder,
+# and set parameters accordingly
+if [ -f 'po/tails.pot' ]; then
+ BRANCH='tails-misc_completed'
+ AFTER_IMPORT='intltool_update_po $(po_languages)'
+elif [ -f 'po/tails-greeter.pot' ]; then
+ BRANCH='tails-greeter_completed'
+ AFTER_IMPORT='./setup.py build_i18n'
+elif [ -f 'po/liveusb-creator.pot' ]; then
+ BRANCH='liveusb-creator_completed'
+ AFTER_IMPORT='make pot && rename -f "s,\.new\$,," po/*.new'
+elif [ -f 'po/tails-persistence-setup.pot' ]; then
+ BRANCH='tails-persistence-setup_completed'
+ AFTER_IMPORT='make -C po pot && make -C po update-po'
+elif [ -f 'po/whisperback.pot' ]; then
+ BRANCH='whisperback_completed'
+ AFTER_IMPORT=''
+else
+ echo "Current folder is not a project known to this script!"
+ exit 1
+fi
+
# Clone or update the translation repository
if [ -d "$TOR_TRANSLATION_DIR" ]; then
- $GIT_IN_TOR_TRANSLATION_DIR fetch origin
+ eval "$GIT_IN_TOR_TRANSLATION_DIR fetch origin"
else
- mkdir -p tmp
- git clone $TOR_TRANSLATION_REMOTE $TOR_TRANSLATION_DIR
+ mkdir -p "$SCRIPT_DIR/tmp"
+ git clone "$TOR_TRANSLATION_REMOTE" "$TOR_TRANSLATION_DIR"
fi
# Checkout the correct branch
-$GIT_IN_TOR_TRANSLATION_DIR checkout tails-misc_completed
-$GIT_IN_TOR_TRANSLATION_DIR reset --hard origin/tails-misc_completed
+eval "$GIT_IN_TOR_TRANSLATION_DIR checkout \"$BRANCH\""
+eval "$GIT_IN_TOR_TRANSLATION_DIR reset --hard \"origin/$BRANCH\""
# For each completely translated language, merge it,
# unless it is translated outside Transifex
-for po_file in $TOR_TRANSLATION_DIR/*.po; do
+find "$TOR_TRANSLATION_DIR" -name '*.po' | while read po_file; do
lang=$(basename "$po_file" | tr - _ | sed 's/\.po$//')
if ! lang_is_excluded "$lang"; then
@@ -43,4 +66,6 @@ for po_file in $TOR_TRANSLATION_DIR/*.po; do
done
# Update PO files
-intltool_update_po $(po_languages)
+if [ -n "$AFTER_IMPORT" ]; then
+ eval "$AFTER_IMPORT"
+fi