Add basic manifest generator.
[tails.git] / refresh-translations
blob40ab45f57fb65ebc6ffbf89e89e38b61a82ccd0d
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.sh \
13 /usr/local/bin/electrum \
14 /usr/local/bin/tails-upgrade-frontend-wrapper \
15 /usr/local/sbin/tails-spoof-mac \
16 /usr/local/sbin/tails-i2p \
17 /usr/local/sbin/i2p-browser \
18 /usr/local/bin/tor-browser \
19 /usr/local/sbin/unsafe-browser"
21 LOCALE_BASEDIR=config/chroot_local-includes/usr/share/locale
23 ### External libraries
25 . config/chroot_local-includes/usr/local/lib/tails-shell-library/po.sh
27 ### Functions
29 prog_potfile () {
30 prog=$1
32 progpath="config/chroot_local-includes$prog"
33 domain=$(basename $prog)
34 echo "tmp/pot/${domain}.pot"
37 refresh_pot () {
38 prog=$1
39 proglang=$2
41 progpath="config/chroot_local-includes$prog"
42 pot=$(prog_potfile $prog)
44 mkdir -p "$(dirname $pot)"
46 if [ -e "${progpath}" ]; then
47 xgettext --language="${proglang}" --from-code=UTF-8 \
48 -o "${pot}" "${progpath}"
49 sed -i "s@^\"Content-Type: text/plain\; charset=CHARSET\\\n\"@\"Content-Type: text/plain\; charset=UTF-8\\\n\"@" "${pot}"
53 po_file () {
54 locale=$1
56 echo "po/${locale}.po"
59 mo_file () {
60 locale=$1
62 echo "${LOCALE_BASEDIR}/${locale}/LC_MESSAGES/tails.mo"
65 refresh_mo () {
66 for locale in "$@" ; do
67 po=$(po_file $locale)
68 mo=$(mo_file $locale)
69 mkdir -p $(dirname "$mo")
70 msgfmt -o "${mo}" "${po}"
71 done
74 no_left_out_files () {
75 (cd po && intltool-update --maintain)
76 [ ! -e po/missing ] || return 1
77 return 0
80 intltool_update_pot () {
82 cd po
83 intltool-update --pot --gettext-package=tails
87 intltool_merge () {
88 grep -E --no-filename '[^ #]*\.(desktop|directory)\.in$' po/POTFILES.in \
89 | while read infile ; do
90 intltool-merge --quiet --desktop-style --utf8 \
91 po "$infile" "${infile%.in}"
92 done
95 intltool_report () {
96 (cd po && intltool-update --report --gettext-package=tails)
99 ### Main
101 # Update POT files
102 mkdir -p tmp/pot
103 for prog in $PERL_PROGS ; do refresh_pot $prog Perl ; done
104 for prog in $PYTHON_PROGS ; do refresh_pot $prog Python ; done
105 for prog in $SHELL_PROGS ; do refresh_pot $prog Shell ; done
106 intltool_update_pot
108 # If left out files are detected, intltool-update --maintain writes
109 # them to po/missing.
110 no_left_out_files || exit 3
112 # Update PO files
113 intltool_update_po $(po_languages)
115 # Update files that are actually used at runtime
116 refresh_mo $(po_languages)
117 intltool_merge
119 # Report back
120 intltool_report