Bug 10942: Provide a way for package upgrades to update template translations
[koha.git] / debian / koha-common.postinst
1 #!/bin/sh
2
3 set -e
4
5 NAME="koha-common"
6 # Default to "no"
7 AUTOMATIC_TRANSLATIONS_UPDATE="no"
8
9 . /usr/share/debconf/confmodule
10
11 # Read configuration variable file if it is present
12 if [ -r /etc/default/$NAME ]; then
13     . /etc/default/$NAME
14 fi
15
16 conf=/etc/mysql/koha-common.cnf
17 if [ ! -e "$conf" ] && [ ! -L "$conf" ]
18 then
19     ln -s debian.cnf "$conf"
20 fi
21
22 #DEBHELPER#
23
24 koha-upgrade-schema $(koha-list)
25
26 if [ "$AUTOMATIC_TRANSLATIONS_UPDATE" = "yes" ]; then
27     for lang in $(koha-translate --list | grep -v -x "en"); do
28         if koha-translate --update $lang; then
29             echo "Updated the $lang translations."
30         else
31             cat <<EOF
32 ERROR: an error was found when updating '$lang' translations. Please manually
33 run 'koha-translate --update $lang'. Run man koha-translate for more options.
34 EOF
35         fi
36     done
37 else
38     # no auto-update, check update needed and warn if needed
39     if koha-translate --list | grep -v -q -x "en"; then
40         # translations installed, update needed
41         cat <<EOF
42 Warning: template translations are not set to be automatically updated.
43 Please manually run 'koha-translate --update lang_code' to update them.
44
45 You can run 'koha-translate --list' to get a list of the installed translations codes.
46 EOF
47     fi
48 fi
49
50 db_stop
51
52 exit 0