View | Details | Raw Unified | Return to bug 16749
Collapse All | Expand All

(-)a/debian/scripts/koha-translate (-21 / +59 lines)
Lines 17-22 Link Here
17
# You should have received a copy of the GNU General Public License
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/>.
18
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
19
20
# Read configuration variable file if it is present
21
[ -r /etc/default/koha-common ] && . /etc/default/koha-common
20
22
21
set -e
23
set -e
22
24
Lines 38-48 $scriptname Link Here
38
This script lets you manage your Koha templates translations.
40
This script lets you manage your Koha templates translations.
39
41
40
Usage:
42
Usage:
41
$scriptname --list|-l [--available|-a]
43
$scriptname --list|-l [--available|-a]  [-d|--dev instance]
42
$scriptname --check|-c language_code
44
$scriptname --check|-c language_code]   [-d|--dev instance]
43
$scriptname --install|-i language_code
45
$scriptname --install|-i language_code] [-d|--dev instance]
44
$scriptname --update|-u language_code
46
$scriptname --update|-u language_code]  [-d|--dev instance]
45
$scriptname --remove|-r language_code
47
$scriptname --remove|-r language_code]  [-d|--dev instance]
46
$scriptname --help|-h
48
$scriptname --help|-h
47
49
48
    -l | --list           List the installed or available (combined with -a)
50
    -l | --list           List the installed or available (combined with -a)
Lines 54-59 $scriptname --help|-h Link Here
54
    -r | --remove         Remove the specified language translations
56
    -r | --remove         Remove the specified language translations
55
    -v | --verbose        Be more verbose on the translation process
57
    -v | --verbose        Be more verbose on the translation process
56
    -h | --help           Display this help message
58
    -h | --help           Display this help message
59
    -d | --dev            Limit actions to a specific dev instance
57
60
58
EOF
61
EOF
59
}
62
}
Lines 80-87 print_available() Link Here
80
83
81
print_installed()
84
print_installed()
82
{
85
{
83
    ( ls -1 $KOHA_INSTALL_DIR/opac/htdocs/opac-tmpl/bootstrap/ ; \
86
    ( ls -1 $KOHA_HOME/$OPAC_TMPL/bootstrap/ ; \
84
        ls -1 $KOHA_INSTALL_DIR/opac/htdocs/opac-tmpl/prog/ 2> /dev/null ) | \
87
        ls -1 $KOHA_HOME/$OPAC_TMPL/prog/ 2> /dev/null ) | \
85
        sort | uniq | \
88
        sort | uniq | \
86
        grep -v -e images -e itemtypeimg -x -e en -e css -e js -e less -e lib
89
        grep -v -e images -e itemtypeimg -x -e en -e css -e js -e less -e lib
87
}
90
}
Lines 107-113 install_lang() Link Here
107
            else
110
            else
108
                # Check po files are present
111
                # Check po files are present
109
                check_lang_po_files $lang
112
                check_lang_po_files $lang
110
                env PERL5LIB="$KOHA_LIB_DIR:$TRANSLATE_DIR" KOHA_CONF="$KOHA_CONF_FILE"\
113
                env PERL5LIB="$PERL5LIB:$TRANSLATE_DIR" \
114
                    KOHA_CONF="$KOHA_CONF" \
111
                    $PERL_CMD $TRANSLATE_DIR/translate install $translate_opts $lang
115
                    $PERL_CMD $TRANSLATE_DIR/translate install $translate_opts $lang
112
            fi
116
            fi
113
        else
117
        else
Lines 153-162 remove_lang() Link Here
153
        fi
157
        fi
154
158
155
        if print_installed | grep -q $lang; then
159
        if print_installed | grep -q $lang; then
156
            rm -rf $KOHA_INSTALL_DIR/opac/htdocs/opac-tmpl/prog/$lang
160
            rm -rf $KOHA_HOME/$OPAC_TMPL/bootstrap/$lang
157
            rm -rf $KOHA_INSTALL_DIR/opac/htdocs/opac-tmpl/ccsr/$lang
161
            rm -rf $KOHA_HOME/$INTRANET_TMPL/prog/$lang
158
            rm -rf $KOHA_INSTALL_DIR/opac/htdocs/opac-tmpl/bootstrap/$lang
159
            rm -rf $KOHA_INSTALL_DIR/intranet/htdocs/intranet-tmpl/prog/$lang
160
        else
162
        else
161
            die "Error: the selected language is not installed."
163
            die "Error: the selected language is not installed."
162
        fi
164
        fi
Lines 198-218 set_action() Link Here
198
    fi
200
    fi
199
}
201
}
200
202
201
# Global PATH variables
203
set_dev()
202
KOHA_INSTALL_DIR="/usr/share/koha"
204
{
203
KOHA_LIB_DIR="/usr/share/koha/lib"
205
    if echo $1 | egrep -q "^[^-]"; then
204
KOHA_CONF_FILE="/etc/koha/koha-conf-site.xml.in"
206
        dev=$1
205
TRANSLATE_DIR="$KOHA_INSTALL_DIR/misc/translator"
207
    else
206
PO_DIR="$TRANSLATE_DIR/po"
208
        die "Error: dev parameter with wrong instance name"
207
PERL_CMD=`which perl`
209
    fi
210
}
211
212
check_koha_conf()
213
{
214
    if [ "$dev" != "" ]; then
215
        KOHA_CONF=/etc/koha/sites/$dev/koha-conf.xml
216
    elif [ -z $KOHA_CONF ]; then
217
        KOHA_CONF=/etc/koha/koha-conf-site.xml.in
218
    fi
219
}
220
221
init_template_paths()
222
{
223
    # Template paths
224
    if [ "$dev" != "" ]; then
225
        OPAC_TMPL=opac/htdocs/opac-tmpl
226
        INTRANET_TMPL=intranet/htdocs/intranet-tmpl
227
    else
228
        OPAC_TMPL=koha-tmpl/opac-tmpl
229
        INTRANET_TMPL=koha-tmpl/intranet-tmpl
230
    fi
231
    TRANSLATE_DIR="$KOHA_HOME/misc/translator"
232
    PO_DIR="$TRANSLATE_DIR/po"
233
}
208
234
209
# Control variables
235
# Control variables
210
list_all=""
236
list_all=""
211
op=""
237
op=""
212
language=""
238
language=""
213
verbose="no"
239
verbose="no"
240
dev=""
214
241
215
# We accept at most 2 parameters
242
# We accept at most 4 parameters
216
[ $# -ge 1 ] && [ $# -le 4 ] || ( usage ; die "Error: wrong parameters" )
243
[ $# -ge 1 ] && [ $# -le 4 ] || ( usage ; die "Error: wrong parameters" )
217
244
218
# Read parameters
245
# Read parameters
Lines 243-248 while [ $# -gt 0 ]; do Link Here
243
        -v|--verbose)
270
        -v|--verbose)
244
            verbose="yes"
271
            verbose="yes"
245
            shift ;;
272
            shift ;;
273
        -d|--dev)
274
            if [ $# -lt 2 ]; then
275
                die "Error: dev parameter without instance"
276
            fi
277
            shift
278
            set_dev $1
279
            shift ;;
246
        -*)
280
        -*)
247
            usage
281
            usage
248
            die "Error: unknown parameter $1." ;;
282
            die "Error: unknown parameter $1." ;;
Lines 253-258 while [ $# -gt 0 ]; do Link Here
253
287
254
done
288
done
255
289
290
if [ "$dev" != "" ]; then adjust_paths_dev_install $dev; fi
291
check_koha_conf
292
init_template_paths
293
PERL_CMD=`which perl`
294
256
# Process the requested actions
295
# Process the requested actions
257
case $op in
296
case $op in
258
    "help")
297
    "help")
259
- 

Return to bug 16749