Store architecture for each binary package.
[tails.git] / refresh-translations
blob2139cb0d1dc0616192f99c0f4c8a4f016afff3f8
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/lib/tails-htp-notify-user \
8 /usr/local/lib/tails-virt-notify-user"
9 PYTHON_PROGS="/etc/whisperback/config.py \
10 /usr/local/bin/tails-about /usr/local/sbin/tails-additional-software"
11 SHELL_PROGS="/etc/NetworkManager/dispatcher.d/60-tor-ready.sh \
12 /usr/local/bin/electrum \
13 /usr/local/bin/icedove \
14 /usr/local/bin/tails-upgrade-frontend-wrapper \
15 /usr/local/lib/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"
20 JAVASCRIPT_PROGS=" \
21 /usr/share/gnome-shell/extensions/shutdown-helper@tails.boum.org/extension.js \
22 /usr/share/gnome-shell/extensions/torstatus@tails.boum.org/extension.js \
25 LOCALE_BASEDIR=config/chroot_local-includes/usr/share/locale
27 ### External libraries
29 . config/chroot_local-includes/usr/local/lib/tails-shell-library/po.sh
31 ### Functions
33 prog_potfile () {
34 prog=$1
36 progpath="config/chroot_local-includes$prog"
37 case $prog in
38 /usr/share/gnome-shell/extensions/shutdown-helper@tails.boum.org/extension.js)
39 domain=shutdown-helper-extension.js
42 domain=$(basename $prog)
44 esac
45 echo "tmp/pot/${domain}.pot"
48 refresh_pot () {
49 prog=$1
50 proglang=$2
52 progpath="config/chroot_local-includes$prog"
53 pot=$(prog_potfile $prog)
55 mkdir -p "$(dirname $pot)"
57 if [ -e "${progpath}" ]; then
58 xgettext --language="${proglang}" --from-code=UTF-8 \
59 -o "${pot}" "${progpath}"
60 sed -i "s@^\"Content-Type: text/plain\; charset=CHARSET\\\n\"@\"Content-Type: text/plain\; charset=UTF-8\\\n\"@" "${pot}"
64 po_file () {
65 locale=$1
67 echo "po/${locale}.po"
70 mo_file () {
71 locale=$1
73 echo "${LOCALE_BASEDIR}/${locale}/LC_MESSAGES/tails.mo"
76 refresh_mo () {
77 for locale in "$@" ; do
78 po=$(po_file $locale)
79 mo=$(mo_file $locale)
80 mkdir -p $(dirname "$mo")
81 msgfmt -o "${mo}" "${po}"
82 done
85 no_left_out_files () {
86 (cd po && intltool-update --maintain)
87 [ ! -e po/missing ] || return 1
88 return 0
91 intltool_update_pot () {
93 cd po
94 intltool-update --pot --gettext-package=tails
98 intltool_merge () {
99 grep -E --no-filename '[^ #]*\.(desktop|directory)\.in$' po/POTFILES.in \
100 | while read infile ; do
101 intltool-merge --quiet --desktop-style --utf8 \
102 po "$infile" "${infile%.in}"
103 done
106 intltool_report () {
107 (cd po && intltool-update --report --gettext-package=tails)
110 ### Main
112 # Update POT files
113 mkdir -p tmp/pot
114 for prog in $PERL_PROGS ; do refresh_pot $prog Perl ; done
115 for prog in $PYTHON_PROGS ; do refresh_pot $prog Python ; done
116 for prog in $SHELL_PROGS ; do refresh_pot $prog Shell ; done
117 for prog in $JAVASCRIPT_PROGS ; do refresh_pot $prog JavaScript ; done
118 intltool_update_pot
120 # If left out files are detected, intltool-update --maintain writes
121 # them to po/missing.
122 no_left_out_files || exit 3
124 # Update PO files
125 intltool_update_po $(po_languages)
127 # Update files that are actually used at runtime
128 refresh_mo $(po_languages)
129 intltool_merge
131 # Report back
132 intltool_report