Thunderbird: Refresh apparmor profile for TB60 (refs: #15091).
[tails.git] / refresh-translations
blob95b5950705c3ae9dca7c7bd943fd67296a89833e
1 #! /bin/sh
3 set -e
4 set -u
6 PERL_PROGS="/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/electrum \
11 /usr/local/bin/liferea \
12 /usr/local/bin/tails-about \
13 /usr/local/bin/tails-screen-locker \
14 /usr/local/bin/tails-upgrade-frontend-wrapper \
15 /usr/local/sbin/tails-additional-software"
16 SHELL_PROGS="/etc/NetworkManager/dispatcher.d/60-tor-ready.sh \
17 /usr/local/bin/keepassx \
18 /usr/local/lib/tails-spoof-mac \
19 /usr/local/bin/tor-browser \
20 /usr/local/sbin/unsafe-browser"
21 JAVASCRIPT_PROGS=" \
22 /usr/share/gnome-shell/extensions/status-menu-helper@tails.boum.org/extension.js \
23 /usr/share/gnome-shell/extensions/torstatus@tails.boum.org/extension.js \
26 LOCALE_BASEDIR=config/chroot_local-includes/usr/share/locale
28 ### External libraries
30 . config/chroot_local-includes/usr/local/lib/tails-shell-library/common.sh
31 . config/chroot_local-includes/usr/local/lib/tails-shell-library/po.sh
33 ### Functions
35 normalize_pot () {
36 sed --regexp-extended \
37 -i 's@^"Content-Type: text/plain; charset=CHARSET\\n"@"Content-Type: text/plain; charset=UTF-8\\n"@' \
38 "${@}"
41 prog_potfile () {
42 prog=$1
44 progpath="config/chroot_local-includes$prog"
45 case $prog in
46 /usr/share/gnome-shell/extensions/status-menu-helper@tails.boum.org/extension.js)
47 domain=status-menu-helper-extension.js
50 domain=$(basename $prog)
52 esac
53 echo "tmp/pot/${domain}.pot"
56 create_pot () {
57 prog=$1
58 proglang=$2
59 progpath="config/chroot_local-includes${prog}"
60 if [ -e "${progpath}" ]; then
61 pot="$(prog_potfile "${prog}")"
62 mkdir -p "$(dirname ${pot})"
63 xgettext --language="${proglang}" --from-code=UTF-8 \
64 -o "${pot}" "${progpath}"
65 normalize_pot "${pot}"
66 else
67 echo "error: We are supposed to create a POT file for '${prog}'" \
68 "but '${progpath}' does not exist"
69 exit 1
73 po_file () {
74 locale=$1
76 echo "po/${locale}.po"
79 mo_file () {
80 locale=$1
82 echo "${LOCALE_BASEDIR}/${locale}/LC_MESSAGES/tails.mo"
85 refresh_mo () {
86 for locale in "$@" ; do
87 po=$(po_file $locale)
88 mo=$(mo_file $locale)
89 mkdir -p $(dirname "$mo")
90 msgfmt -o "${mo}" "${po}"
91 done
94 no_left_out_files () {
95 (cd po && intltool-update --maintain)
96 [ ! -e po/missing ] || return 1
97 return 0
100 intltool_update_pot () {
102 cd po
103 cp -a tails.pot tails.pot.orig
104 intltool-update --pot --gettext-package=tails
105 normalize_pot tails.pot tails.pot.orig
107 if [ "${FORCE:-}" = yes ]; then
108 echo "Force-updating 'tails.pot'."
109 rm tails.pot.orig
110 elif diff_without_pot_creation_date_and_comments -q tails.pot.orig tails.pot; then
111 echo "Only header or comment changes in tails.pot: keeping the old one"
112 mv tails.pot.orig tails.pot
113 else
114 echo "Real changes in tails.pot: switching to the updated one"
115 rm tails.pot.orig
120 intltool_merge_desktop () {
121 extract_from_file_between_markers po/POTFILES.in \
122 '^# Files updated by intltool-update --desktop-style' '^$' \
123 | while read infile ; do
124 intltool-merge --quiet --desktop-style --utf8 \
125 po "$infile" "${infile%.in}"
126 done
129 intltool_merge_xml () {
130 extract_from_file_between_markers po/POTFILES.in \
131 '^# Files updated by intltool-update --xml-style' '^$' \
132 | while read infile ; do
133 intltool-merge --quiet --xml-style --utf8 \
134 po "$infile" "${infile%.in}"
135 done
138 ### Main
140 FORCE=no
141 KEEP_TMP_POT=no
142 while [ -n "${@:-}" ]; do
143 case "${1:-}" in
144 '--force')
145 FORCE=yes
147 '--keep-tmp-pot')
148 KEEP_TMP_POT=yes
151 echo "Unknown option: ${1}"
152 exit 1
154 esac
155 shift
156 done
158 # Schedule clean up
159 trap "rm -fr po/*.new po/*.orig ; [ "$KEEP_TMP_POT" = yes ] || rm -fr tmp/pot" EXIT
161 # Update POT files
162 mkdir -p tmp/pot
163 for prog in $PERL_PROGS ; do create_pot $prog Perl ; done
164 for prog in $PYTHON_PROGS ; do create_pot $prog Python ; done
165 for prog in $SHELL_PROGS ; do create_pot $prog Shell ; done
166 for prog in $JAVASCRIPT_PROGS ; do create_pot $prog JavaScript ; done
167 intltool_update_pot
169 # If left out files are detected, intltool-update --maintain writes
170 # them to po/missing.
171 no_left_out_files || exit 3
173 # Update PO files
174 intltool_update_po $(po_languages)
176 # Update files that are actually used at runtime
177 refresh_mo $(po_languages)
178 intltool_merge_desktop
179 intltool_merge_xml
180 chmod +x config/chroot_local-includes/etc/skel/Desktop/*.desktop