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"
20 echo -n "$EXCLUDE_LANGS" |
grep -qs -w "$lang"
24 LANG_DOT_PO_LAYOUT
=yes
26 # Detect which project is in current folder,
27 # and set parameters accordingly
28 if [ -f 'po/tails.pot' ]; then
29 BRANCH
='tails-misc_release'
30 AFTER_IMPORT
='intltool_update_po $(po_languages)'
31 elif [ -f 'po/onioncircuits.pot' ]; then
33 POTFILE
=onioncircuits.pot
34 BRANCH
='tails-onioncircuits_release'
35 AFTER_IMPORT
='./setup.py build_i18n && ( cd po && for po in *.po ; do msgmerge --update "$po" onioncircuits.pot ; done )'
36 elif [ -f 'po/whisperback.pot' ]; then
37 BRANCH
='whisperback_release'
40 echo "Current folder is not a project known to this script!"
44 # Clone or update the translation repository
45 if [ -d "$TOR_TRANSLATION_DIR" ]; then
46 eval "$GIT_IN_TOR_TRANSLATION_DIR fetch origin"
48 mkdir
-p "$SCRIPT_DIR/tmp"
49 git clone
"$TOR_TRANSLATION_REMOTE" "$TOR_TRANSLATION_DIR"
52 # Checkout the correct branch
53 eval "$GIT_IN_TOR_TRANSLATION_DIR checkout \"$BRANCH\""
54 eval "$GIT_IN_TOR_TRANSLATION_DIR reset --hard \"origin/$BRANCH\""
56 # Ensure we only keep PO files that are still present in the Transifex
57 # branch we import from.
58 find "$TAILS_PO_DIR" -name '*.po' -delete
60 # For each completely translated language, merge it,
61 # unless it is translated outside Transifex
62 if [ "$LANG_DOT_PO_LAYOUT" = yes ] ; then
63 find "$TOR_TRANSLATION_DIR" -name '*.po' |
sort |
while read po_file
; do
64 lang
=$
(basename "$po_file" |
tr - _ |
sed 's/\.po$//')
66 ! lang_is_excluded
"$lang" ||
continue
67 if [ "$(cat "$po_file" | count_translated_strings)" -lt 1 ]; then
68 echo "Skipping $lang, that has no translated strings."
71 echo "Importing translation for $lang..."
72 cp "$po_file" "$TAILS_PO_DIR"
75 find "$TOR_TRANSLATION_DIR" -name '*.pot' |
sort |
while read po_file
; do
76 lang
=$
(basename $
(dirname "$po_file" |
tr - _ |
sed 's/\.pot$//'))
78 ! lang_is_excluded
"$lang" ||
continue
79 if [ "$(cat "$po_file" | count_translated_strings)" -lt 1 ]; then
80 echo "Skipping $lang, that has no translated strings."
83 echo "Importing translation for $lang..."
84 cp "$po_file" "$TAILS_PO_DIR/${lang}.po"
89 if [ -n "${AFTER_IMPORT:-}" ]; then