Bug 8251 - Patrons get incorrectly debarred
[koha.git] / misc / translator / translate
blobf0c12c9f1205cf895083f5c1c981f6eee4f4db8f
1 #!/usr/bin/perl
3 # Copyright (C) 2010 Tamil s.a.r.l.
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 package Main;
22 use strict;
23 use warnings;
25 use LangInstaller;
26 use Getopt::Long;
27 use Pod::Usage;
30 my $verbose = 0;
31 my $pref = 0;
32 my $all = 0;
33 GetOptions(
34 'v|verbose' => \$verbose,
35 'p' => \$pref,
36 'a|all' => \$all,
40 sub usage {
41 pod2usage( -verbose => 2 );
42 exit;
46 usage() if $#ARGV != 1 && $#ARGV != 0;
48 my ($cmd, $lang) = @ARGV;
49 $cmd = lc $cmd;
50 if ( $cmd =~ /create|install|update/ ) {
51 my $installer = LangInstaller->new( $lang, $pref, $verbose );
52 if ( $cmd !~ /create/ && $lang && not $lang ~~ $installer->{langs} ) {
53 print "Unsupported language: $lang\n";
54 exit;
56 if ( $all ) {
57 usage() if $cmd eq 'create';
58 for my $lang ( @{$installer->{langs}} ) {
59 $installer->set_lang( $lang );
60 $installer->$cmd();
63 else {
64 $installer->$cmd();
67 else {
68 usage();
73 =head1 NAME
75 translate - Handle templates and preferences translation
77 =head1 SYNOPSYS
79 translate create fr-FR
80 translate update fr-FR
81 translate install fr-FR
82 translate -p install fr-FR
83 translate install
85 =head1 DESCRIPTION
87 In Koha, three categories of information are translated based on standard GNU
88 .po files: opac templates pages, intranet templates and system preferences. The
89 script is a wrapper. It allows to quickly create/update/install .po files for a
90 given language or for all available languages.
92 =head1 USAGE
94 =over
96 =item translate create F<lang>
98 Create 3 .po files in F</misc/translator/po> subdirectory: (1) from opac pages
99 templates, (2) intranet templates, and (3) from preferences. English 'en'
100 version of templates and preferences are used as references.
102 =over
104 =item F<lang>-opac.po
106 Contains extracted text from english (en) OPAC templates found in
107 <KOHA_ROOT>/koha-tmpl/opac-tmpl/prog/en/ directory.
109 =item F<lang>-intranet.po
111 Contains extracted text from english (en) intranet templates found in
112 <KOHA_ROOT>/koha-tmpl/intranet-tmpl/prog/en/ directory.
114 =item F<lang>-pref.po
116 Contains extracted text from english (en) preferences. They are found in files
117 located in <KOHA_ROOT>/koha-tmpl/intranet-tmpl/prog/en/admin/preferences
118 directory.
120 =back
122 =item translate [-p] update F<lang>
124 Update .po files in F<po> directory, named F<lang>-*.po. Without F<lang>, all
125 available languages are updated. With -p option, only preferences .po file is
126 updated.
128 =item translate [-p] install F<lang>
130 Use .po files to translate the english version of templayes and preferences files
131 and copy those files in the appropriate directory. Without F<lang>, all
132 available languages are installed. With -p option, only preferences .po file is
133 updated.
135 =back
137 =cut