. /usr/share/debconf/confmodule
+CONFIGFILE=/etc/koha/koha-common.conf
+
+if [ -e $CONFIGFILE ]; then
+ . $CONFIGFILE || true
+ # Put the current values into debconf
+ UPDATE="true"
+ if [ "$AUTOMATIC_TRANSLATIONS_UPDATE" = "no" ] ; then
+ UPDATE="false"
+ fi
+ db_set koha-common/automatically-update-translations "$UPDATE"
+else
+ # True is the default
+ db_set koha-common/automatically-update-translations true
+fi
+
if dpkg --compare-versions "$2" lt-nl 3.4 ; then
db_input high koha-common/3.2-3.4-upgrade-notice || true
fi
-db_go
+
+db_input medium koha-common/automatically-update-translations || true
+
+db_go || true
. /usr/share/debconf/confmodule
# Read configuration variable file if it is present
-if [ -r /etc/koha/koha-common.conf ]; then
- . /etc/koha/koha-common.conf
+CONFIG=/etc/koha/koha-common.conf
+if [ -r $CONFIG ]; then
+ . $CONFIG
fi
conf=/etc/mysql/koha-common.cnf
koha-upgrade-schema $(koha-list)
+# Generate a config file if one doesn't exist already
+if [ ! -e $CONFIG ]; then
+ cat <<EOF > $CONFIG
+## Automatic template translation update
+#
+# This variable controls whether template translations should
+# be updated automatically on koha-common package upgrades.
+# Options: 'yes' (default)
+# 'no'
+# Note: if you choose 'no' then you will have to issue
+# $ koha-translate --update <lang_code>
+#
+AUTOMATIC_TRANSLATIONS_UPDATE="yes"
+EOF
+fi
+
+# Substitute the values from debconf into the file.
+db_get koha-common/automatically-update-translations
+UPDATE="$RET"
+if [ "$UPDATE" = "false" ]; then
+ UPDATE="no"
+else
+ UPDATE="yes"
+fi
+# In case they were removed/commented out, we add it in.
+grep -Eq '^ *AUTOMATIC_TRANSLATIONS_UPDATE=' $CONFIG || \
+ echo "AUTOMATIC_TRANSLATIONS_UPDATE=" >> $CONFIG
+
+sed -e "s/^ *AUTOMATIC_TRANSLATIONS_UPDATE=.*/AUTOMATIC_TRANSLATIONS_UPDATE=\"$UPDATE\"/" < $CONFIG > $CONFIG.tmp
+mv -f $CONFIG.tmp $CONFIG
+
if [ "$AUTOMATIC_TRANSLATIONS_UPDATE" = "yes" ]; then
for lang in $(koha-translate --list | grep -v -x "en"); do
if koha-translate --update $lang; then
should be largely operational during the process, but some things,
particularly to do with items, may appear strange until the upgrade and
re-index is complete.
+
+Template: koha-common/automatically-update-translations
+Type: boolean
+Default: true
+Description: automatically update translations
+ When Koha is upgraded, any existing translated templates can be regenerated
+ to keep everything in sync. Select "yes" if you want this.