Bug 16194: Do not consider xslt as valid theme dir in LangInstaller.pm
[koha.git] / misc / translator / translate
index 90f2950..697a3db 100755 (executable)
@@ -4,18 +4,18 @@
 #
 # 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 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 3 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.
+# 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.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 package Main;
 
@@ -30,9 +30,11 @@ 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,
 );
 
@@ -48,8 +50,8 @@ usage() if $#ARGV != 1 && $#ARGV != 0;
 my ($cmd, $lang) = @ARGV;
 $cmd = lc $cmd;
 if ( $cmd =~ /create|install|update/ ) {
-    my $installer = LangInstaller->new( $lang, $pref );
-    if ( $cmd !~ /create/ && $lang && not $lang ~~ $installer->{langs} ) {
+    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;
     }
@@ -57,11 +59,11 @@ if ( $cmd =~ /create|install|update/ ) {
         usage() if $cmd eq 'create';
         for my $lang ( @{$installer->{langs}} ) {
             $installer->set_lang( $lang );
-            $installer->$cmd();
+            $installer->$cmd(\@files);
         }
     }
     else {
-        $installer->$cmd();
+        $installer->$cmd(\@files);
     }
 }
 else {
@@ -79,6 +81,7 @@ translate - Handle templates and preferences translation
   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
 
@@ -91,6 +94,8 @@ 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>
@@ -101,10 +106,10 @@ version of templates and preferences are used as references.
 
 =over
 
-=item F<lang>-opac.po
+=item F<lang>-opac-{theme}.po
 
 Contains extracted text from english (en) OPAC templates found in
-<KOHA_ROOT>/koha-tmpl/opac-tmpl/prog/en/ directory.
+<KOHA_ROOT>/koha-tmpl/opac-tmpl/{theme}/en/ directory.
 
 =item F<lang>-intranet.po
 
@@ -125,13 +130,16 @@ 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] install F<lang>
+=item translate [-p|-f] install F<lang>
 
-Use .po files to translate the english version of templayes and preferences files
+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