Bug 10942: Provide a way for package upgrades to update template translations
This patch adds a new config variable AUTOMATIC_TRANSLATIONS_UPDATE at /etc/default/koha-common that is used to control whether the upgrade process should trigger a $ koha-translate --update <lang_code> command for each installed template translation language. To test: - Have a koha-common setup with some languages installed (e.g. koha-translate --install es-ES) - Apply the patch and build a package for it. - Install it. - A new AUTOMATIC_TRANSLATIONS_UPDATE config variable should be in place at /etc/default/koha-common - Set AUTOMATIC_TRANSLATIONS_UPDATE to 'yes' - Re-install the package to trigger the post-install script - Verify that translations get updated. Edit: added a warning message for the case AUTOMATIC_TRANSLATIONS_UPDATE=no and there are translations installed (so they need to get updated). Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Works as advertised, default behaviour doesn't change. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Robin Sheat <robin@catalyst.net.nz> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
45ce7431d4
commit
33cc81bbc3
2 changed files with 46 additions and 0 deletions
13
debian/koha-common.default
vendored
13
debian/koha-common.default
vendored
|
@ -1,3 +1,16 @@
|
|||
## General koha-common default options
|
||||
|
||||
PERL5LIB="/usr/share/koha/lib"
|
||||
|
||||
## Automatic template translation update
|
||||
#
|
||||
# This variable controls whether template translations should
|
||||
# be updated automatically on koha-common package upgrades.
|
||||
# Options: 'yes'
|
||||
# 'no' (default)
|
||||
# Note: if you choose 'no' then you will have to issue
|
||||
# $ koha-translate --update <lang_code>
|
||||
#
|
||||
#AUTOMATIC_TRANSLATIONS_UPDATE="no"
|
||||
|
||||
## End of general koha-common default options
|
||||
|
|
33
debian/koha-common.postinst
vendored
33
debian/koha-common.postinst
vendored
|
@ -2,8 +2,17 @@
|
|||
|
||||
set -e
|
||||
|
||||
NAME="koha-common"
|
||||
# Default to "no"
|
||||
AUTOMATIC_TRANSLATIONS_UPDATE="no"
|
||||
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
# Read configuration variable file if it is present
|
||||
if [ -r /etc/default/$NAME ]; then
|
||||
. /etc/default/$NAME
|
||||
fi
|
||||
|
||||
conf=/etc/mysql/koha-common.cnf
|
||||
if [ ! -e "$conf" ] && [ ! -L "$conf" ]
|
||||
then
|
||||
|
@ -14,6 +23,30 @@ fi
|
|||
|
||||
koha-upgrade-schema $(koha-list)
|
||||
|
||||
if [ "$AUTOMATIC_TRANSLATIONS_UPDATE" = "yes" ]; then
|
||||
for lang in $(koha-translate --list | grep -v -x "en"); do
|
||||
if koha-translate --update $lang; then
|
||||
echo "Updated the $lang translations."
|
||||
else
|
||||
cat <<EOF
|
||||
ERROR: an error was found when updating '$lang' translations. Please manually
|
||||
run 'koha-translate --update $lang'. Run man koha-translate for more options.
|
||||
EOF
|
||||
fi
|
||||
done
|
||||
else
|
||||
# no auto-update, check update needed and warn if needed
|
||||
if koha-translate --list | grep -v -q -x "en"; then
|
||||
# translations installed, update needed
|
||||
cat <<EOF
|
||||
Warning: template translations are not set to be automatically updated.
|
||||
Please manually run 'koha-translate --update lang_code' to update them.
|
||||
|
||||
You can run 'koha-translate --list' to get a list of the installed translations codes.
|
||||
EOF
|
||||
fi
|
||||
fi
|
||||
|
||||
db_stop
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in a new issue