Merge branch 'feature/incremental-upgrades' into devel
[tails/vicves.git] / refresh-translations
blob23ba9fefd88b4858e7dfe8fcf318c7dc6a3dfd18
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 /usr/local/bin/tails-start-i2p \
8 /usr/local/bin/tails-virt-notify-user"
9 PYTHON_PROGS="/etc/whisperback/config.py /usr/local/bin/shutdown_helper_applet \
10 /usr/local/bin/tails-about /usr/local/sbin/tails-additional-software"
11 SHELL_PROGS="/usr/local/bin/tails-update-frontend-wrapper \
12 /usr/local/sbin/unsafe-browser /usr/share/tails/truecrypt-wrapper.disabled"
14 LANGUAGES=$(for po in po/*.po ; do rel="${po%.po}" ; echo "${rel#po/}"; done)
15 LOCALE_BASEDIR=config/chroot_local-includes/usr/share/locale
17 ### Functions
19 prog_potfile () {
20 prog=$1
22 progpath="config/chroot_local-includes$prog"
23 domain=$(basename $prog)
24 echo "tmp/pot/${domain}.pot"
27 refresh_pot () {
28 prog=$1
29 proglang=$2
31 progpath="config/chroot_local-includes$prog"
32 pot=$(prog_potfile $prog)
34 mkdir -p "$(dirname $pot)"
36 if [ -e "${progpath}" ]; then
37 xgettext --language="${proglang}" --from-code=UTF-8 \
38 -o "${pot}" "${progpath}"
39 sed -i "s@^\"Content-Type: text/plain\; charset=CHARSET\\\n\"@\"Content-Type: text/plain\; charset=UTF-8\\\n\"@" "${pot}"
43 po_file () {
44 locale=$1
46 echo "po/${locale}.po"
49 mo_file () {
50 locale=$1
52 echo "${LOCALE_BASEDIR}/${locale}/LC_MESSAGES/tails.mo"
55 refresh_mo () {
56 for locale in "$@" ; do
57 po=$(po_file $locale)
58 mo=$(mo_file $locale)
59 mkdir -p $(dirname "$mo")
60 msgfmt -o "${mo}" "${po}"
61 done
64 no_left_out_files () {
65 (cd po && intltool-update --maintain)
66 [ ! -e po/missing ] || return 1
67 return 0
70 intltool_update_pot () {
72 cd po
73 intltool-update --pot --gettext-package=tails
77 intltool_update_po () {
79 cd po
80 for locale in "$@" ; do
81 intltool-update --dist --gettext-package=tails $locale
82 done
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 $LANGUAGES
114 # Update files that are actually used at runtime
115 refresh_mo $LANGUAGES
116 intltool_merge
118 # Report back
119 intltool_report