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

(-)a/debian/docs/koha-translate.xml (+73 lines)
Line 0 Link Here
1
<article xmlns='http://docbook.org/ns/docbook'>
2
<title>koha-translate</title>
3
<info>
4
<productname>Koha</productname> is the first free software library automation package.
5
<author>
6
  <orgname>The Koha Community</orgname>
7
  <uri>http://koha-community.org/</uri>
8
</author>
9
</info>
10
11
<refentry xml:id="koha-translate">
12
13
  <refmeta>
14
    <refentrytitle>koha-translate</refentrytitle>
15
    <manvolnum>8</manvolnum>
16
  </refmeta>
17
18
  <refnamediv>
19
    <refname>koha-translate</refname>
20
    <refpurpose>Manage Koha templates translations</refpurpose>
21
    <refclass>UNIX/Linux</refclass>
22
  </refnamediv>
23
24
  <refsynopsisdiv>
25
    <cmdsynopsis>
26
      <command>koha-translate</command> <arg><option>-i</option>|<option>--install</option></arg> <arg><option>-u</option>|<option>--update</option></arg> <arg><option>-r</option>|<option>--remove</option></arg> <arg choice="req"  rep="norepeat"><replaceable>lang_code</replaceable></arg>
27
      <command>koha-translate</command> <arg><option>-l</option>|<option>--list</option></arg> <arg><option>-a</option>|<option>--available</option></arg>
28
    </cmdsynopsis>
29
  </refsynopsisdiv>
30
  
31
  <refsect1><title>Options</title>
32
  <variablelist> 
33
    <varlistentry>
34
      <term><option>-a, --available</option></term>
35
      <listitem>
36
        <para>(For use with --list) List the available language translations.</para>
37
      </listitem>
38
    </varlistentry>
39
    <varlistentry>
40
      <term><option>-i, --install</option></term>
41
      <listitem>
42
        <para>Install the specified lang_code language translation.</para>
43
      </listitem>
44
    </varlistentry>
45
    <varlistentry>
46
      <term><option>-l, --list</option></term>
47
      <listitem>
48
        <para>List the installed or available (combined with -a) language translations.</para>
49
      </listitem>
50
    </varlistentry>
51
    <varlistentry>
52
      <term><option>-r, --remove</option></term>
53
      <listitem>
54
        <para>Remove the specified lang_code language translation.</para>
55
      </listitem>
56
    </varlistentry>
57
    <varlistentry>
58
      <term><option>-u, --update</option></term>
59
      <listitem>
60
        <para>Update the specified lang_code language translation.</para>
61
      </listitem>
62
    </varlistentry>
63
64
 </variablelist>
65
  </refsect1>
66
67
  <refsect1><title>Description</title>
68
  <para>Manage Koha templates translations.</para>
69
  </refsect1>
70
  
71
</refentry>
72
73
</article>
(-)a/debian/koha-common.install (+1 lines)
Lines 28-33 debian/scripts/koha-run-backups usr/sbin Link Here
28
debian/scripts/koha-shell                   usr/sbin
28
debian/scripts/koha-shell                   usr/sbin
29
debian/scripts/koha-start-zebra             usr/sbin
29
debian/scripts/koha-start-zebra             usr/sbin
30
debian/scripts/koha-stop-zebra              usr/sbin
30
debian/scripts/koha-stop-zebra              usr/sbin
31
debian/scripts/koha-translate               usr/sbin
31
debian/scripts/koha-upgrade-schema          usr/sbin
32
debian/scripts/koha-upgrade-schema          usr/sbin
32
debian/scripts/koha-upgrade-to-3.4          usr/sbin
33
debian/scripts/koha-upgrade-to-3.4          usr/sbin
33
debian/tmp_docbook/*.8                      usr/share/man/man8
34
debian/tmp_docbook/*.8                      usr/share/man/man8
(-)a/debian/scripts/koha-translate (-1 / +205 lines)
Line 0 Link Here
0
- 
1
#!/bin/sh
2
#
3
# koha-translate -- Manage Koha translations.
4
# Copyright 2013 Tomás Cohen Arazi
5
#                Universidad Nacional de Córdoba
6
# 
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.
11
# 
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.
16
# 
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/>.
19
20
21
set -e
22
23
usage()
24
{
25
    local scriptname=$(basename $0)
26
    cat <<EOF
27
$scriptname
28
29
This scripts lets you manage your Koha templates translations.
30
31
Usage:
32
$scriptname --list|-l [--all|-a]
33
$scriptname --install|-i language_code
34
$scriptname --update|-u language_code
35
$scriptname --remove|-r language_code
36
$scriptname -h
37
38
    -l | --list           List the installed or available (combined with -a)
39
                          language translations
40
    -a | --available      Used in conjunction with -l to show all languages
41
    -i | --install        Install the specified language translations
42
    -u | --update         Update the specified language translations
43
    -r | --remove         Remove the specified language translations
44
    -h | --help           Display this help message
45
46
EOF
47
}
48
49
die() {
50
    echo "$@" 1>&2
51
    exit 1
52
}
53
54
list() {
55
    all=$1
56
    if [ "$all" != "" ]; then
57
        print_available
58
    else
59
        print_installed
60
    fi 
61
}
62
63
print_available()
64
{
65
    for i in $(ls $PO_DIR | grep opac)
66
    do
67
        echo `basename $i -i-opac-t-prog-v-3006000.po`
68
    done
69
}
70
71
print_installed()
72
{
73
    for i in $(ls $KOHA_INSTALL_DIR/opac/htdocs/opac-tmpl/prog/ | grep -v -e images -e itemtypeimg)
74
    do
75
        echo $i
76
    done
77
}
78
79
install_lang()
80
{
81
    lang=$1
82
83
    if [ "$lang" != "" ]; then
84
85
        if [ "$lang" = "en" ]; then
86
            die "Error: the default language (en) is already installed."
87
        fi
88
        
89
        if print_available | grep -q $lang; then
90
            if print_installed | grep -q $lang; then
91
                die "Error: the selected language is already installed. Try --update if you want to re-install it."
92
            else
93
                env PERL5LIB="$KOHA_LIB_DIR:$TRANSLATE_DIR" KOHA_CONF="$KOHA_CONF_FILE"\
94
                    $PERL_CMD $TRANSLATE_DIR/translate install $lang
95
            fi
96
        else
97
            die "Error: the selected language is not currently available."
98
        fi
99
100
    else
101
        die "Error: no language code supplied."
102
    fi
103
}
104
105
update_lang()
106
{
107
    lang=$1
108
109
    if [ "$lang" != "" ]; then
110
111
        if [ "$lang" = "en" ]; then
112
            die "Error: the default language (en) cannot be updated."
113
        fi
114
115
        if print_installed | grep -q $lang; then
116
            env PERL5LIB="$KOHA_LIB_DIR:$TRANSLATE_DIR" KOHA_CONF="$KOHA_CONF_FILE"\
117
                $PERL_CMD $TRANSLATE_DIR/translate update $lang
118
        else
119
            die "Error: the selected language is not currently installed. Try --install."
120
        fi
121
    else
122
        die "Error: no language code supplied."
123
    fi
124
}
125
126
remove_lang()
127
{
128
    lang=$1
129
130
    if [ "$lang" != "" ]; then
131
132
        if [ "$lang" = "en" ]; then
133
            die "Error: the default language (en) cannot be removed."
134
        fi
135
136
        if print_installed | grep -q $lang; then 
137
            rm -rf $KOHA_INSTALL_DIR/opac/htdocs/opac-tmpl/prog/$lang
138
            rm -rf $KOHA_INSTALL_DIR/opac/htdocs/opac-tmpl/ccsr/$lang
139
            rm -rf $KOHA_INSTALL_DIR/intranet/htdocs/intranet-tmpl/prog/$lang
140
        else
141
            die "Error: the selected language is not already installed."
142
        fi
143
    else
144
        die "Error: no language code supplied."
145
    fi
146
}
147
148
# Global PATH variables
149
KOHA_INSTALL_DIR="/usr/share/koha"
150
KOHA_LIB_DIR="/usr/share/koha/lib"
151
KOHA_CONF_FILE="/etc/koha/koha-conf-site.xml.in"
152
TRANSLATE_DIR="$KOHA_INSTALL_DIR/misc/translator"
153
PO_DIR="$TRANSLATE_DIR/po"
154
PERL_CMD=`which perl`
155
# Control variables
156
list_all=""
157
158
# Read parameters
159
while true ; do
160
    case "$1" in
161
        -h|--help)
162
            op="help"
163
            break ;;
164
        -i|--install)
165
            op="install"
166
            language="$2"
167
            shift 2 ;;
168
        -u|--update)
169
            op="update"
170
            language="$2"
171
            shift 2 ;;
172
        -r|--remove)
173
            op="remove"
174
            language="$2"
175
            shift 2 ;;
176
        -l|--list)
177
            op="list"
178
            shift ;;
179
        -a|--available)
180
            list_all=1
181
            shift ;;
182
        *)
183
            break ;;
184
    esac
185
done
186
187
# Process the requested actions
188
case $op in
189
    "help")
190
        usage ;;
191
    "list")
192
        list $list_all ;;
193
    "install")
194
        install_lang $language ;;
195
    "update")
196
        update_lang $language ;;
197
    "remove")
198
        remove_lang $language ;;
199
    *)
200
        usage
201
        die "Error: wrong parameters..." ;;
202
esac
203
204
exit 0
205

Return to bug 10041