Fix link destination
[tails-test.git] / refresh-translations
blobdebbb4de9716ce182c7cbff8b7ad78f2c05fa78c
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 /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/iceweasel \
14 /usr/local/bin/tails-upgrade-frontend-wrapper \
15 /usr/local/sbin/tails-spoof-mac \
16 /usr/local/sbin/unsafe-browser /usr/share/tails/truecrypt-wrapper.disabled"
18 LOCALE_BASEDIR=config/chroot_local-includes/usr/share/locale
20 ### External libraries
22 . config/chroot_local-includes/usr/local/lib/tails-shell-library/po.sh
24 ### Functions
26 prog_potfile () {
27 prog=$1
29 progpath="config/chroot_local-includes$prog"
30 domain=$(basename $prog)
31 echo "tmp/pot/${domain}.pot"
34 refresh_pot () {
35 prog=$1
36 proglang=$2
38 progpath="config/chroot_local-includes$prog"
39 pot=$(prog_potfile $prog)
41 mkdir -p "$(dirname $pot)"
43 if [ -e "${progpath}" ]; then
44 xgettext --language="${proglang}" --from-code=UTF-8 \
45 -o "${pot}" "${progpath}"
46 sed -i "s@^\"Content-Type: text/plain\; charset=CHARSET\\\n\"@\"Content-Type: text/plain\; charset=UTF-8\\\n\"@" "${pot}"
50 po_file () {
51 locale=$1
53 echo "po/${locale}.po"
56 mo_file () {
57 locale=$1
59 echo "${LOCALE_BASEDIR}/${locale}/LC_MESSAGES/tails.mo"
62 refresh_mo () {
63 for locale in "$@" ; do
64 po=$(po_file $locale)
65 mo=$(mo_file $locale)
66 mkdir -p $(dirname "$mo")
67 msgfmt -o "${mo}" "${po}"
68 done
71 no_left_out_files () {
72 (cd po && intltool-update --maintain)
73 [ ! -e po/missing ] || return 1
74 return 0
77 intltool_update_pot () {
79 cd po
80 intltool-update --pot --gettext-package=tails
84 intltool_merge () {
85 grep -E --no-filename '[^ #]*\.(desktop|directory)\.in$' po/POTFILES.in \
86 | while read infile ; do
87 intltool-merge --quiet --desktop-style --utf8 \
88 po "$infile" "${infile%.in}"
89 done
92 intltool_report () {
93 (cd po && intltool-update --report --gettext-package=tails)
96 ### Main
98 # Update POT files
99 mkdir -p tmp/pot
100 for prog in $PERL_PROGS ; do refresh_pot $prog Perl ; done
101 for prog in $PYTHON_PROGS ; do refresh_pot $prog Python ; done
102 for prog in $SHELL_PROGS ; do refresh_pot $prog Shell ; done
103 intltool_update_pot
105 # If left out files are detected, intltool-update --maintain writes
106 # them to po/missing.
107 no_left_out_files || exit 3
109 # Update PO files
110 intltool_update_po $(po_languages)
112 # Update files that are actually used at runtime
113 refresh_mo $(po_languages)
114 intltool_merge
116 # Report back
117 intltool_report