3 # koha-translate -- Manage Koha translations.
4 # Copyright 2013 Tomás Cohen Arazi
5 # Universidad Nacional de Córdoba
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 local scriptname
=$
(basename $0)
30 This script lets you manage your Koha templates translations.
33 $scriptname --list|-l [--all|-a]
34 $scriptname --check|-c language_code
35 $scriptname --install|-i language_code
36 $scriptname --update|-u language_code
37 $scriptname --remove|-r language_code
40 -l | --list List the installed or available (combined with -a)
42 -a | --available Used in conjunction with -l to show all languages
43 -c | --check Check that the language .PO files are present
44 -i | --install Install the specified language translations
45 -u | --update Update the specified language translations
46 -r | --remove Remove the specified language translations
47 -h | --help Display this help message
62 if [ "$all" != "" ]; then
71 # Loop over only one opac theme
72 for i
in $
( ls $PO_DIR |
grep opac-t-prog
); do
73 echo `basename $i -i-opac-t-prog-v-3006000.po`
79 ls $KOHA_INSTALL_DIR/opac
/htdocs
/opac-tmpl
/prog
/ | \
80 grep -v -e images
-e itemtypeimg
87 if [ "$lang" != "" ]; then
89 if [ "$lang" = "en" ]; then
90 die
"Error: the default language (en) is already installed."
93 if print_available |
grep -q $lang; then
94 if print_installed |
grep -q $lang; then
95 die
"Error: the selected language is already installed. Try --update if you want to re-install it."
97 # Check po files are present
98 check_lang_po_files
$lang
99 env PERL5LIB
="$KOHA_LIB_DIR:$TRANSLATE_DIR" KOHA_CONF
="$KOHA_CONF_FILE"\
100 $PERL_CMD $TRANSLATE_DIR/translate
install $lang
103 die
"Error: the selected language is not currently available."
107 die
"Error: no language code supplied."
115 if [ "$lang" != "" ]; then
117 if [ "$lang" = "en" ]; then
118 die
"Error: the default language (en) cannot be updated."
121 if print_installed |
grep -q $lang; then
122 # Check po files are present
123 check_lang_po_files
$lang
127 die
"Error: the selected language is not currently installed. Try --install."
130 die
"Error: no language code supplied."
138 if [ "$lang" != "" ]; then
140 if [ "$lang" = "en" ]; then
141 die
"Error: the default language (en) cannot be removed."
144 if print_installed |
grep -q $lang; then
145 rm -rf $KOHA_INSTALL_DIR/opac
/htdocs
/opac-tmpl
/prog
/$lang
146 rm -rf $KOHA_INSTALL_DIR/opac
/htdocs
/opac-tmpl
/ccsr
/$lang
147 rm -rf $KOHA_INSTALL_DIR/intranet
/htdocs
/intranet-tmpl
/prog
/$lang
149 die
"Error: the selected language is not already installed."
152 die
"Error: no language code supplied."
156 check_lang_po_files
()
160 po_files
="$PO_DIR/$lang-i-opac-t-prog-v-3006000.po
161 $PO_DIR/$lang-opac-ccsr.po
162 $PO_DIR/$lang-i-staff-t-prog-v-3006000.po
163 $PO_DIR/$lang-pref.po"
165 if [ "$lang" != "" ]; then
167 for po_file
in $po_files; do
168 if [ ! -f $po_file ]; then
169 die
"Error: $po_file not found."
173 die
"Error: no language code supplied."
179 if [ "$op" = "" ]; then
182 die
"Error: only one action can be specified."
186 # Global PATH variables
187 KOHA_INSTALL_DIR
="/usr/share/koha"
188 KOHA_LIB_DIR
="/usr/share/koha/lib"
189 KOHA_CONF_FILE
="/etc/koha/koha-conf-site.xml.in"
190 TRANSLATE_DIR
="$KOHA_INSTALL_DIR/misc/translator"
191 PO_DIR
="$TRANSLATE_DIR/po"
192 PERL_CMD
=`which perl`
199 # We accept at most 2 parameters
200 [ $# -ge 1 ] && [ $# -le 3 ] ||
( usage
; die
"Error: wrong parameters" )
203 while [ $# -gt 0 ]; do
229 die
"Error: unknown parameter $1." ;;
237 # Process the requested actions
244 install_lang
$language ;;
246 update_lang
$language ;;
248 remove_lang
$language ;;
250 check_lang_po_files
$language ;;
253 die
"Error: wrong parameters..." ;;