updated PO files
[tails-test.git] / import-translations
blob9281e37d532142bcc893487dfebb1f693165ce22
1 #!/bin/sh
3 set -e
4 set -u
6 EXCLUDE_LANGS='fr'
7 TAILS_PO_DIR='po'
8 SCRIPT_DIR=$(readlink -f "$(dirname "$0")")
9 TOR_TRANSLATION_REMOTE='https://git.torproject.org/translation.git'
10 TOR_TRANSLATION_DIR="$SCRIPT_DIR/tmp/tor-translation"
11 GIT_IN_TOR_TRANSLATION_DIR="git \
12 --work-tree=\"$TOR_TRANSLATION_DIR\" \
13 --git-dir=\"$TOR_TRANSLATION_DIR/.git\""
15 ### External libraries
16 . "$SCRIPT_DIR/config/chroot_local-includes/usr/local/lib/tails-shell-library/po.sh"
18 lang_is_excluded () {
19 local lang="$1"
20 echo -n "$EXCLUDE_LANGS" | grep -qs -w "$lang"
23 # Detect which project is in current folder,
24 # and set parameters accordingly
25 if [ -f 'po/tails.pot' ]; then
26 BRANCH='tails-misc_completed'
27 AFTER_IMPORT='intltool_update_po $(po_languages)'
28 elif [ -f 'po/tails-greeter.pot' ]; then
29 BRANCH='tails-greeter_completed'
30 AFTER_IMPORT='./setup.py build_i18n'
31 elif [ -f 'po/tails-iuk.pot' ]; then
32 BRANCH='tails-iuk_completed'
33 AFTER_IMPORT='make -C po pot && make -C po update-po'
34 elif [ -f 'po/tails-perl5lib.pot' ]; then
35 BRANCH='tails-perl5lib_completed'
36 AFTER_IMPORT='make -C po pot && make -C po update-po'
37 elif [ -f 'po/liveusb-creator.pot' ]; then
38 BRANCH='liveusb-creator_completed'
39 AFTER_IMPORT='make pot && rename -f "s,\.new\$,," po/*.new'
40 elif [ -f 'po/tails-persistence-setup.pot' ]; then
41 BRANCH='tails-persistence-setup_completed'
42 AFTER_IMPORT='make -C po pot && make -C po update-po'
43 elif [ -f 'po/whisperback.pot' ]; then
44 BRANCH='whisperback_completed'
45 AFTER_IMPORT=''
46 else
47 echo "Current folder is not a project known to this script!"
48 exit 1
51 # Clone or update the translation repository
52 if [ -d "$TOR_TRANSLATION_DIR" ]; then
53 eval "$GIT_IN_TOR_TRANSLATION_DIR fetch origin"
54 else
55 mkdir -p "$SCRIPT_DIR/tmp"
56 git clone "$TOR_TRANSLATION_REMOTE" "$TOR_TRANSLATION_DIR"
59 # Checkout the correct branch
60 eval "$GIT_IN_TOR_TRANSLATION_DIR checkout \"$BRANCH\""
61 eval "$GIT_IN_TOR_TRANSLATION_DIR reset --hard \"origin/$BRANCH\""
63 # For each completely translated language, merge it,
64 # unless it is translated outside Transifex
65 find "$TOR_TRANSLATION_DIR" -name '*.po' | while read po_file; do
66 lang=$(basename "$po_file" | tr - _ | sed 's/\.po$//')
68 if ! lang_is_excluded "$lang"; then
69 echo "Importing translation for $lang..."
70 cp "$po_file" "$TAILS_PO_DIR"
72 done
74 # Update PO files
75 if [ -n "$AFTER_IMPORT" ]; then
76 eval "$AFTER_IMPORT"