7 SCRIPT_DIR
=$
(readlink
-f "$(dirname "$0")")
8 TOR_TRANSLATION_REMOTE
='https://gitlab.torproject.org/tpo/translation.git'
9 TOR_TRANSLATION_DIR
="$SCRIPT_DIR/tmp/tor-translation"
10 GIT_IN_TOR_TRANSLATION_DIR
="git \
11 --work-tree=\"$TOR_TRANSLATION_DIR\" \
12 --git-dir=\"$TOR_TRANSLATION_DIR/.git\""
14 ### External libraries
15 .
"$SCRIPT_DIR/config/chroot_local-includes/usr/local/lib/tails-shell-library/po.sh"
18 LANG_DOT_PO_LAYOUT
=yes
20 # Detect which project is in current folder,
21 # and set parameters accordingly
22 # shellcheck disable=SC2016
23 if [ -f 'po/tails.pot' ]; then
25 AFTER_IMPORT
='intltool_update_po $(po_languages)'
26 elif [ -f 'po/onioncircuits.pot' ]; then
28 BRANCH
='tails-onioncircuits_release'
29 AFTER_IMPORT
='./setup.py build_i18n && ( cd po && for po in *.po ; do msgmerge --update "$po" onioncircuits.pot ; done )'
31 echo "Current folder is not a project known to this script!"
35 # Clone or update the translation repository
36 if [ -d "$TOR_TRANSLATION_DIR" ]; then
37 eval "$GIT_IN_TOR_TRANSLATION_DIR remote set-url origin ${TOR_TRANSLATION_REMOTE}"
38 eval "$GIT_IN_TOR_TRANSLATION_DIR fetch origin"
40 mkdir
-p "$SCRIPT_DIR/tmp"
41 git clone
"$TOR_TRANSLATION_REMOTE" "$TOR_TRANSLATION_DIR"
44 # Checkout the correct branch
45 eval "$GIT_IN_TOR_TRANSLATION_DIR checkout \"$BRANCH\""
46 eval "$GIT_IN_TOR_TRANSLATION_DIR reset --hard \"origin/$BRANCH\""
48 # Ensure we only keep PO files that are still present in the
49 # branch we import from.
50 find "$TAILS_PO_DIR" -name '*.po' -delete
52 # For each completely translated language, merge it.
53 if [ "$LANG_DOT_PO_LAYOUT" = yes ] ; then
54 find "$TOR_TRANSLATION_DIR" -name '*.po' |
sort |
while read -r po_file
; do
55 lang
=$
(basename "$po_file" |
tr - _ |
sed 's/\.po$//')
57 if [ "$(count_translated_strings < "$po_file")" -lt 1 ]; then
58 echo "Skipping $lang, that has no translated strings."
61 echo "Importing translation for $lang..."
62 cp "$po_file" "$TAILS_PO_DIR"
65 find "$TOR_TRANSLATION_DIR" -name '*.pot' |
sort |
while read -r po_file
; do
66 lang
=$
(basename "$(dirname "$po_file" | tr - _ | sed 's/\.pot$//')")
68 if [ "$(count_translated_strings < "$po_file")" -lt 1 ]; then
69 echo "Skipping $lang, that has no translated strings."
72 echo "Importing translation for $lang..."
73 cp "$po_file" "$TAILS_PO_DIR/${lang}.po"
78 if [ -n "${AFTER_IMPORT:-}" ]; then