35a88a5c44
Using perl v5.18, the following is warned on updating/installing templates: Smartmatch is experimental at ./translate line 54. Moreover, the following should exist with previous perl versions: perlcritic xgettext Subroutine prototypes used at line 29, column 1. See page 194 of PBP. (Severity: 5) Subroutine prototypes used at line 44, column 1. See page 194 of PBP. (Severity: 5) Subroutine prototypes used at line 60, column 1. See page 194 of PBP. (Severity: 5) Subroutine prototypes used at line 72, column 1. See page 194 of PBP. (Severity: 5) Subroutine prototypes used at line 89, column 1. See page 194 of PBP. (Severity: 5) Variable declared in conditional statement at line 105, column 13. Declare variables outside of the condition. (Severity: 5) Subroutine prototypes used at line 127, column 1. See page 194 of PBP. (Severity: 5) Subroutine prototypes used at line 136, column 1. See page 194 of PBP. (Severity: 5) Variable declared in conditional statement at line 190, column 7. Declare variables outside of the condition. (Severity: 5) Subroutine prototypes used at line 237, column 1. See page 194 of PBP. (Severity: 5) Bareword file handle opened at line 238, column 5. See pages 202,204 of PBP. (Severity: 5) Two-argument "open" used at line 238, column 5. See page 207 of PBP. (Severity: 5) Subroutine prototypes used at line 277, column 1. See page 194 of PBP. (Severity: 5) Subroutine prototypes used at line 311, column 1. See page 194 of PBP. (Severity: 5) Bareword file handle opened at line 350, column 9. See pages 202,204 of PBP. (Severity: 5) Two-argument "open" used at line 350, column 9. See page 207 of PBP. (Severity: 5) Bareword file handle opened at line 353, column 5. See pages 202,204 of PBP. (Severity: 5) Bareword file handle opened at line 359, column 5. See pages 202,204 of PBP. (Severity: 5) Two-argument "open" used at line 359, column 5. See page 207 of PBP. (Severity: 5) perl -wc xgettext.pl \1 better written as $1 at TmplTokenizer.pm line 474. main::token_negligible_p() called too early to check prototype at xgettext.pl line 52. xgettext.pl syntax OK Test plan: Apply this patch and verify the warnings/errors does not appear anymore and no regression is found on creating/updating/installing templates. Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> Work as described, no koha-qa errros. Tested with perl v5.18.2 No warnings, no problem detected on create/update/install i18n files Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
146 lines
3.7 KiB
Perl
Executable file
146 lines
3.7 KiB
Perl
Executable file
#!/usr/bin/perl
|
|
|
|
# Copyright (C) 2010 Tamil s.a.r.l.
|
|
#
|
|
# This file is part of Koha.
|
|
#
|
|
# Koha is free software; you can redistribute it and/or modify it under the
|
|
# terms of the GNU General Public License as published by the Free Software
|
|
# Foundation; either version 2 of the License, or (at your option) any later
|
|
# version.
|
|
#
|
|
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along
|
|
# with Koha; if not, write to the Free Software Foundation, Inc.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
package Main;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use LangInstaller;
|
|
use Getopt::Long;
|
|
use Pod::Usage;
|
|
|
|
|
|
my $verbose = 0;
|
|
my $pref = 0;
|
|
my $all = 0;
|
|
my @files;
|
|
GetOptions(
|
|
'v|verbose' => \$verbose,
|
|
'p' => \$pref,
|
|
'f:s' => \@files,
|
|
'a|all' => \$all,
|
|
);
|
|
|
|
|
|
sub usage {
|
|
pod2usage( -verbose => 2 );
|
|
exit;
|
|
}
|
|
|
|
|
|
usage() if $#ARGV != 1 && $#ARGV != 0;
|
|
|
|
my ($cmd, $lang) = @ARGV;
|
|
$cmd = lc $cmd;
|
|
if ( $cmd =~ /create|install|update/ ) {
|
|
my $installer = LangInstaller->new( $lang, $pref, $verbose );
|
|
if ( $cmd ne 'create' and $lang and not grep( /^$lang$/, @{ $installer->{langs} } ) ) {
|
|
print "Unsupported language: $lang\n";
|
|
exit;
|
|
}
|
|
if ( $all ) {
|
|
usage() if $cmd eq 'create';
|
|
for my $lang ( @{$installer->{langs}} ) {
|
|
$installer->set_lang( $lang );
|
|
$installer->$cmd(\@files);
|
|
}
|
|
}
|
|
else {
|
|
$installer->$cmd(\@files);
|
|
}
|
|
}
|
|
else {
|
|
usage();
|
|
}
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
translate - Handle templates and preferences translation
|
|
|
|
=head1 SYNOPSYS
|
|
|
|
translate create fr-FR
|
|
translate update fr-FR
|
|
translate install fr-FR
|
|
translate install fr-FR -f search -f memberentry
|
|
translate -p install fr-FR
|
|
translate install
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
In Koha, three categories of information are translated based on standard GNU
|
|
.po files: opac templates pages, intranet templates and system preferences. The
|
|
script is a wrapper. It allows to quickly create/update/install .po files for a
|
|
given language or for all available languages.
|
|
|
|
=head1 USAGE
|
|
|
|
Use the -v or --verbose parameter to make translator more verbose.
|
|
|
|
=over
|
|
|
|
=item translate create F<lang>
|
|
|
|
Create 3 .po files in F</misc/translator/po> subdirectory: (1) from opac pages
|
|
templates, (2) intranet templates, and (3) from preferences. English 'en'
|
|
version of templates and preferences are used as references.
|
|
|
|
=over
|
|
|
|
=item F<lang>-opac.po
|
|
|
|
Contains extracted text from english (en) OPAC templates found in
|
|
<KOHA_ROOT>/koha-tmpl/opac-tmpl/prog/en/ directory.
|
|
|
|
=item F<lang>-intranet.po
|
|
|
|
Contains extracted text from english (en) intranet templates found in
|
|
<KOHA_ROOT>/koha-tmpl/intranet-tmpl/prog/en/ directory.
|
|
|
|
=item F<lang>-pref.po
|
|
|
|
Contains extracted text from english (en) preferences. They are found in files
|
|
located in <KOHA_ROOT>/koha-tmpl/intranet-tmpl/prog/en/admin/preferences
|
|
directory.
|
|
|
|
=back
|
|
|
|
=item translate [-p] update F<lang>
|
|
|
|
Update .po files in F<po> directory, named F<lang>-*.po. Without F<lang>, all
|
|
available languages are updated. With -p option, only preferences .po file is
|
|
updated.
|
|
|
|
=item translate [-p|-f] install F<lang>
|
|
|
|
Use .po files to translate the english version of templates and preferences files
|
|
and copy those files in the appropriate directory. Without F<lang>, all
|
|
available languages are installed. With -p option, only preferences .po file is
|
|
updated.
|
|
|
|
With -f parameter (repeatable) you can specify specific files to translate. For
|
|
example, -f search will translate all templates containing 'search'.
|
|
|
|
=back
|
|
|
|
=cut
|
|
|