Report++
[tails-test.git] / refresh-translations
blobf22eca1a97fab26ff6610b151f23999bfbfa456a
1 #! /bin/sh
3 set -e
4 set -u
6 PERL_PROGS="/usr/local/bin/gpgApplet /usr/local/bin/tails-security-check \
7 /usr/local/bin/tails-htp-notify-user \
8 /usr/local/bin/tails-virt-notify-user \
9 /usr/local/sbin/tails-restricted-network-detector"
10 PYTHON_PROGS="/etc/whisperback/config.py /usr/local/lib/shutdown-helper-applet \
11 /usr/local/bin/tails-about /usr/local/sbin/tails-additional-software"
12 SHELL_PROGS="/etc/NetworkManager/dispatcher.d/60-tor-ready-notification.sh \
13 /usr/local/bin/tails-upgrade-frontend-wrapper \
14 /usr/local/sbin/tails-spoof-mac \
15 /usr/local/sbin/tails-i2p \
16 /usr/local/sbin/i2p-browser \
17 /usr/local/bin/tor-browser \
18 /usr/local/sbin/unsafe-browser"
20 LOCALE_BASEDIR=config/chroot_local-includes/usr/share/locale
22 ### External libraries
24 . config/chroot_local-includes/usr/local/lib/tails-shell-library/po.sh
26 ### Functions
28 prog_potfile () {
29 prog=$1
31 progpath="config/chroot_local-includes$prog"
32 domain=$(basename $prog)
33 echo "tmp/pot/${domain}.pot"
36 refresh_pot () {
37 prog=$1
38 proglang=$2
40 progpath="config/chroot_local-includes$prog"
41 pot=$(prog_potfile $prog)
43 mkdir -p "$(dirname $pot)"
45 if [ -e "${progpath}" ]; then
46 xgettext --language="${proglang}" --from-code=UTF-8 \
47 -o "${pot}" "${progpath}"
48 sed -i "s@^\"Content-Type: text/plain\; charset=CHARSET\\\n\"@\"Content-Type: text/plain\; charset=UTF-8\\\n\"@" "${pot}"
52 po_file () {
53 locale=$1
55 echo "po/${locale}.po"
58 mo_file () {
59 locale=$1
61 echo "${LOCALE_BASEDIR}/${locale}/LC_MESSAGES/tails.mo"
64 refresh_mo () {
65 for locale in "$@" ; do
66 po=$(po_file $locale)
67 mo=$(mo_file $locale)
68 mkdir -p $(dirname "$mo")
69 msgfmt -o "${mo}" "${po}"
70 done
73 no_left_out_files () {
74 (cd po && intltool-update --maintain)
75 [ ! -e po/missing ] || return 1
76 return 0
79 intltool_update_pot () {
81 cd po
82 intltool-update --pot --gettext-package=tails
86 intltool_merge () {
87 grep -E --no-filename '[^ #]*\.(desktop|directory)\.in$' po/POTFILES.in \
88 | while read infile ; do
89 intltool-merge --quiet --desktop-style --utf8 \
90 po "$infile" "${infile%.in}"
91 done
94 intltool_report () {
95 (cd po && intltool-update --report --gettext-package=tails)
98 ### Main
100 # Update POT files
101 mkdir -p tmp/pot
102 for prog in $PERL_PROGS ; do refresh_pot $prog Perl ; done
103 for prog in $PYTHON_PROGS ; do refresh_pot $prog Python ; done
104 for prog in $SHELL_PROGS ; do refresh_pot $prog Shell ; done
105 intltool_update_pot
107 # If left out files are detected, intltool-update --maintain writes
108 # them to po/missing.
109 no_left_out_files || exit 3
111 # Update PO files
112 intltool_update_po $(po_languages)
114 # Update files that are actually used at runtime
115 refresh_mo $(po_languages)
116 intltool_merge
118 # Report back
119 intltool_report