Bug 18936: Convert issuingrules fields to circulation_rules
[koha.git] / misc / translator / translate
blob59a0c127ee861b534fd86293ed42e3bedaa607ff
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
8 # 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 # Koha is distributed in the hope that it will be useful, but
13 # 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 Koha; if not, see <http://www.gnu.org/licenses>.
20 package Main;
22 use FindBin;
23 use lib $FindBin::Bin;
25 use strict;
26 use warnings;
28 use LangInstaller;
29 use Getopt::Long;
30 use Pod::Usage;
33 my $verbose = 0;
34 my $pref = 0;
35 my $all = 0;
36 my @files;
37 GetOptions(
38 'v|verbose' => \$verbose,
39 'p' => \$pref,
40 'f:s' => \@files,
41 'a|all' => \$all,
45 sub usage {
46 pod2usage( -verbose => 2 );
47 exit;
51 usage() if $#ARGV != 1 && $#ARGV != 0;
53 my ($cmd, $lang) = @ARGV;
54 $cmd = lc $cmd;
55 if ( $cmd =~ /create|install|update/ ) {
56 my $installer = LangInstaller->new( $lang, $pref, $verbose );
57 if ( $cmd ne 'create' and $lang and not grep( /^$lang$/, @{ $installer->{langs} } ) ) {
58 print "Unsupported language: $lang\n";
59 exit;
61 if ( $all ) {
62 usage() if $cmd eq 'create';
63 for my $lang ( @{$installer->{langs}} ) {
64 $installer->set_lang( $lang );
65 $installer->$cmd(\@files);
68 else {
69 $installer->$cmd(\@files);
72 else {
73 usage();
78 =head1 NAME
80 translate - Handle templates and preferences translation
82 =head1 SYNOPSYS
84 translate create fr-FR
85 translate update fr-FR
86 translate install fr-FR
87 translate install fr-FR -f search -f memberentry
88 translate -p install fr-FR
89 translate install
91 =head1 DESCRIPTION
93 In Koha, three categories of information are translated based on standard GNU
94 .po files: opac templates pages, intranet templates and system preferences. The
95 script is a wrapper. It allows to quickly create/update/install .po files for a
96 given language or for all available languages.
98 =head1 USAGE
100 Use the -v or --verbose parameter to make translator more verbose.
102 =over
104 =item translate create F<lang>
106 Create 3 .po files in F</misc/translator/po> subdirectory: (1) from opac pages
107 templates, (2) intranet templates, and (3) from preferences. English 'en'
108 version of templates and preferences are used as references.
110 =over
112 =item F<lang>-opac-{theme}.po
114 Contains extracted text from english (en) OPAC templates found in
115 <KOHA_ROOT>/koha-tmpl/opac-tmpl/{theme}/en/ directory.
117 =item F<lang>-intranet.po
119 Contains extracted text from english (en) intranet templates found in
120 <KOHA_ROOT>/koha-tmpl/intranet-tmpl/prog/en/ directory.
122 =item F<lang>-pref.po
124 Contains extracted text from english (en) preferences. They are found in files
125 located in <KOHA_ROOT>/koha-tmpl/intranet-tmpl/prog/en/admin/preferences
126 directory.
128 =back
130 =item translate [-p] update F<lang>
132 Update .po files in F<po> directory, named F<lang>-*.po. Without F<lang>, all
133 available languages are updated. With -p option, only preferences .po file is
134 updated.
136 =item translate [-p|-f] install F<lang>
138 Use .po files to translate the english version of templates and preferences files
139 and copy those files in the appropriate directory. Without F<lang>, all
140 available languages are installed. With -p option, only preferences .po file is
141 updated.
143 With -f parameter (repeatable) you can specify specific files to translate. For
144 example, -f search will translate all templates containing 'search'.
146 =back
148 =cut