Bug 11431: DBIC update schema
[koha.git] / misc / translator / translate
blob697a3db14a802f5b1d955eb90c99852e26b035cc
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 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 my @files;
34 GetOptions(
35 'v|verbose' => \$verbose,
36 'p' => \$pref,
37 'f:s' => \@files,
38 'a|all' => \$all,
42 sub usage {
43 pod2usage( -verbose => 2 );
44 exit;
48 usage() if $#ARGV != 1 && $#ARGV != 0;
50 my ($cmd, $lang) = @ARGV;
51 $cmd = lc $cmd;
52 if ( $cmd =~ /create|install|update/ ) {
53 my $installer = LangInstaller->new( $lang, $pref, $verbose );
54 if ( $cmd ne 'create' and $lang and not grep( /^$lang$/, @{ $installer->{langs} } ) ) {
55 print "Unsupported language: $lang\n";
56 exit;
58 if ( $all ) {
59 usage() if $cmd eq 'create';
60 for my $lang ( @{$installer->{langs}} ) {
61 $installer->set_lang( $lang );
62 $installer->$cmd(\@files);
65 else {
66 $installer->$cmd(\@files);
69 else {
70 usage();
75 =head1 NAME
77 translate - Handle templates and preferences translation
79 =head1 SYNOPSYS
81 translate create fr-FR
82 translate update fr-FR
83 translate install fr-FR
84 translate install fr-FR -f search -f memberentry
85 translate -p install fr-FR
86 translate install
88 =head1 DESCRIPTION
90 In Koha, three categories of information are translated based on standard GNU
91 .po files: opac templates pages, intranet templates and system preferences. The
92 script is a wrapper. It allows to quickly create/update/install .po files for a
93 given language or for all available languages.
95 =head1 USAGE
97 Use the -v or --verbose parameter to make translator more verbose.
99 =over
101 =item translate create F<lang>
103 Create 3 .po files in F</misc/translator/po> subdirectory: (1) from opac pages
104 templates, (2) intranet templates, and (3) from preferences. English 'en'
105 version of templates and preferences are used as references.
107 =over
109 =item F<lang>-opac-{theme}.po
111 Contains extracted text from english (en) OPAC templates found in
112 <KOHA_ROOT>/koha-tmpl/opac-tmpl/{theme}/en/ directory.
114 =item F<lang>-intranet.po
116 Contains extracted text from english (en) intranet templates found in
117 <KOHA_ROOT>/koha-tmpl/intranet-tmpl/prog/en/ directory.
119 =item F<lang>-pref.po
121 Contains extracted text from english (en) preferences. They are found in files
122 located in <KOHA_ROOT>/koha-tmpl/intranet-tmpl/prog/en/admin/preferences
123 directory.
125 =back
127 =item translate [-p] update F<lang>
129 Update .po files in F<po> directory, named F<lang>-*.po. Without F<lang>, all
130 available languages are updated. With -p option, only preferences .po file is
131 updated.
133 =item translate [-p|-f] install F<lang>
135 Use .po files to translate the english version of templates and preferences files
136 and copy those files in the appropriate directory. Without F<lang>, all
137 available languages are installed. With -p option, only preferences .po file is
138 updated.
140 With -f parameter (repeatable) you can specify specific files to translate. For
141 example, -f search will translate all templates containing 'search'.
143 =back
145 =cut