@@ -, +, @@ --- misc/translator/LangInstaller.pm | 36 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 17 deletions(-) --- a/misc/translator/LangInstaller.pm +++ a/misc/translator/LangInstaller.pm @@ -500,18 +500,22 @@ sub create_messages { my $pot = "$self->{domain}.pot"; my $po = "$self->{path_po}/$self->{lang}-messages.po"; + my $js_pot = "$self->{domain}-js.pot"; + my $js_po = "$self->{path_po}/$self->{lang}-messages-js.po"; - unless ( -f $pot ) { + unless ( -f $pot && -f $js_pot ) { $self->extract_messages(); } say "Create messages ($self->{lang})" if $self->{verbose}; my $locale = $self->locale_name(); system "$self->{msginit} -i $pot -o $po -l $locale --no-translator"; + system "$self->{msginit} -i $js_pot -o $js_po -l $locale --no-translator"; # If msginit failed to correctly set Plural-Forms, set a default one - system "$self->{sed} --in-place $po " - . "--expression='s/Plural-Forms: nplurals=INTEGER; plural=EXPRESSION/Plural-Forms: nplurals=2; plural=(n != 1)/'"; + system "$self->{sed} --in-place " + . "--expression='s/Plural-Forms: nplurals=INTEGER; plural=EXPRESSION/Plural-Forms: nplurals=2; plural=(n != 1)/' " + . "$po $js_po"; } sub update_messages { @@ -519,14 +523,17 @@ sub update_messages { my $pot = "$self->{domain}.pot"; my $po = "$self->{path_po}/$self->{lang}-messages.po"; + my $js_pot = "$self->{domain}-js.pot"; + my $js_po = "$self->{path_po}/$self->{lang}-messages-js.po"; - unless ( -f $pot ) { + unless ( -f $pot && -f $js_pot ) { $self->extract_messages(); } - if ( -f $po ) { + if ( -f $po && -f $js_po ) { say "Update messages ($self->{lang})" if $self->{verbose}; system "$self->{msgmerge} -U $po $pot"; + system "$self->{msgmerge} -U $js_po $js_pot"; } else { $self->create_messages(); } @@ -638,7 +645,7 @@ sub extract_messages { . "-k__p:1c,2 -k__px:1c,2 -k__np:1c,2,3 -k__npx:1c,2,3 " . "-kN__ -kN__n:1,2 -kN__p:1c,2 -kN__np:1c,2,3"; my $xgettext_cmd = "$self->{xgettext} -L Perl $xgettext_common_args " - . "-o $Bin/$self->{domain}-perl.pot -D $tempdir -D $intranetdir"; + . "-o $Bin/$self->{domain}.pot -D $tempdir -D $intranetdir"; $xgettext_cmd .= " $_" foreach (@files_to_scan); if (system($xgettext_cmd) != 0) { @@ -647,7 +654,6 @@ sub extract_messages { my @js_dirs = ( "$intranetdir/koha-tmpl/intranet-tmpl/prog/js", - "$intranetdir/koha-tmpl/intranet-tmpl/prog/en/js", "$intranetdir/koha-tmpl/opac-tmpl/bootstrap/js", ); @@ -668,14 +674,9 @@ sub extract_messages { die "system call failed: $xgettext_cmd"; } - my $msgcat_cmd = "$self->{msgcat} --use-first -o $Bin/$self->{domain}.pot $Bin/$self->{domain}-perl.pot $Bin/$self->{domain}-js.pot"; - if (system($msgcat_cmd) != 0) { - die "system call failed: $msgcat_cmd"; - } - my $replace_charset_cmd = "$self->{sed} --in-place " . - "$Bin/$self->{domain}.pot " . - "--expression='s/charset=CHARSET/charset=UTF-8/'"; + "--expression='s/charset=CHARSET/charset=UTF-8/' " . + "$Bin/$self->{domain}.pot $Bin/$self->{domain}-js.pot"; if (system($replace_charset_cmd) != 0) { die "system call failed: $replace_charset_cmd"; } @@ -688,16 +689,18 @@ sub install_messages { my $modir = "$self->{path_po}/$locale/LC_MESSAGES"; my $pofile = "$self->{path_po}/$self->{lang}-messages.po"; my $mofile = "$modir/$self->{domain}.mo"; + my $js_pofile = "$self->{path_po}/$self->{lang}-messages-js.po"; - if ( not -f $pofile ) { + unless ( -f $pofile && -f $js_pofile ) { $self->create_messages(); } say "Install messages ($locale)" if $self->{verbose}; make_path($modir); system "$self->{msgfmt} -o $mofile $pofile"; - my $js_locale_data = 'var json_locale_data = {"Koha":' . `$self->{po2json} $pofile` . '};'; + my $js_locale_data = 'var json_locale_data = {"Koha":' . `$self->{po2json} $js_pofile` . '};'; my $progdir = $self->{context}->config('intrahtdocs') . '/prog'; + mkdir "$progdir/$self->{lang}/js"; open my $fh, '>', "$progdir/$self->{lang}/js/locale_data.js"; print $fh $js_locale_data; close $fh; @@ -716,7 +719,6 @@ sub remove_pot { my $self = shift; unlink "$Bin/$self->{domain}.pot"; - unlink "$Bin/$self->{domain}-perl.pot"; unlink "$Bin/$self->{domain}-js.pot"; } --