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

(-)a/debian/docs/koha-translate.xml (+79 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><option>-c</option>|<option>--check</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>-c, --check</option></term>
41
      <listitem>
42
        <para>Check if all the .PO files are present for the specified language.</para>
43
      </listitem>
44
    </varlistentry>
45
    <varlistentry>
46
      <term><option>-i, --install</option></term>
47
      <listitem>
48
        <para>Install the specified lang_code language translation.</para>
49
      </listitem>
50
    </varlistentry>
51
    <varlistentry>
52
      <term><option>-l, --list</option></term>
53
      <listitem>
54
        <para>List the installed or available (combined with -a) language translations.</para>
55
      </listitem>
56
    </varlistentry>
57
    <varlistentry>
58
      <term><option>-r, --remove</option></term>
59
      <listitem>
60
        <para>Remove the specified lang_code language translation.</para>
61
      </listitem>
62
    </varlistentry>
63
    <varlistentry>
64
      <term><option>-u, --update</option></term>
65
      <listitem>
66
        <para>Update the specified lang_code language translation.</para>
67
      </listitem>
68
    </varlistentry>
69
70
 </variablelist>
71
  </refsect1>
72
73
  <refsect1><title>Description</title>
74
  <para>Manage Koha templates translations.</para>
75
  </refsect1>
76
77
</refentry>
78
79
</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 / +256 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
27
    cat <<EOF
28
$scriptname
29
30
This script lets you manage your Koha templates translations.
31
32
Usage:
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
38
$scriptname -h
39
40
    -l | --list           List the installed or available (combined with -a)
41
                          language translations
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
48
49
EOF
50
}
51
52
die()
53
{
54
    echo "$@" 1>&2
55
    exit 1
56
}
57
58
list()
59
{
60
    all=$1
61
62
    if [ "$all" != "" ]; then
63
        print_available
64
    else
65
        print_installed
66
    fi
67
}
68
69
print_available()
70
{
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`
74
    done
75
}
76
77
print_installed()
78
{
79
    ls $KOHA_INSTALL_DIR/opac/htdocs/opac-tmpl/prog/ | \
80
        grep -v -e images -e itemtypeimg
81
}
82
83
install_lang()
84
{
85
    lang=$1
86
87
    if [ "$lang" != "" ]; then
88
89
        if [ "$lang" = "en" ]; then
90
            die "Error: the default language (en) is already installed."
91
        fi
92
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."
96
            else
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
101
            fi
102
        else
103
            die "Error: the selected language is not currently available."
104
        fi
105
106
    else
107
        die "Error: no language code supplied."
108
    fi
109
}
110
111
update_lang()
112
{
113
    lang=$1
114
115
    if [ "$lang" != "" ]; then
116
117
        if [ "$lang" = "en" ]; then
118
            die "Error: the default language (en) cannot be updated."
119
        fi
120
121
        if print_installed | grep -q $lang; then
122
            # Check po files are present
123
            check_lang_po_files $lang
124
            remove_lang $lang
125
            install_lang $lang
126
        else
127
            die "Error: the selected language is not currently installed. Try --install."
128
        fi
129
    else
130
        die "Error: no language code supplied."
131
    fi
132
}
133
134
remove_lang()
135
{
136
    lang=$1
137
138
    if [ "$lang" != "" ]; then
139
140
        if [ "$lang" = "en" ]; then
141
            die "Error: the default language (en) cannot be removed."
142
        fi
143
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
148
        else
149
            die "Error: the selected language is not already installed."
150
        fi
151
    else
152
        die "Error: no language code supplied."
153
    fi
154
}
155
156
check_lang_po_files()
157
{
158
    lang=$1
159
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"
164
165
    if [ "$lang" != "" ]; then
166
167
        for po_file in $po_files; do
168
            if [ ! -f $po_file ]; then
169
                die "Error: $po_file not found."
170
            fi
171
        done
172
    else
173
        die "Error: no language code supplied."
174
    fi
175
}
176
177
set_action()
178
{
179
    if [ "$op" = "" ]; then
180
        op=$1
181
    else
182
        die "Error: only one action can be specified."
183
    fi
184
}
185
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`
193
194
# Control variables
195
list_all=""
196
op=""
197
language=""
198
199
# We accept at most 2 parameters
200
[ $# -ge 1 ] && [ $# -le 3 ] || ( usage ; die "Error: wrong parameters" )
201
202
# Read parameters
203
while [ $# -gt 0 ]; do
204
205
    case "$1" in
206
        -h|--help)
207
            op="help"
208
            break ;;
209
        -c|--check)
210
            set_action "check"
211
            shift ;;
212
        -i|--install)
213
            set_action "install"
214
            shift ;;
215
        -u|--update)
216
            set_action "update"
217
            shift ;;
218
        -r|--remove)
219
            set_action "remove"
220
            shift ;;
221
        -l|--list)
222
            set_action "list"
223
            shift ;;
224
        -a|--available)
225
            list_all=1
226
            shift ;;
227
        -*)
228
            usage
229
            die "Error: unknown parameter $1." ;;
230
        *)
231
            language=$1
232
            shift ;;
233
    esac
234
235
done
236
237
# Process the requested actions
238
case $op in
239
    "help")
240
        usage ;;
241
    "list")
242
        list $list_all ;;
243
    "install")
244
        install_lang $language ;;
245
    "update")
246
        update_lang $language ;;
247
    "remove")
248
        remove_lang $language ;;
249
    "check")
250
        check_lang_po_files $language ;;
251
    *)
252
        usage
253
        die "Error: wrong parameters..." ;;
254
esac
255
256
exit 0

Return to bug 10041