Lines 500-517
sub create_messages {
Link Here
|
500 |
|
500 |
|
501 |
my $pot = "$self->{domain}.pot"; |
501 |
my $pot = "$self->{domain}.pot"; |
502 |
my $po = "$self->{path_po}/$self->{lang}-messages.po"; |
502 |
my $po = "$self->{path_po}/$self->{lang}-messages.po"; |
|
|
503 |
my $js_pot = "$self->{domain}-js.pot"; |
504 |
my $js_po = "$self->{path_po}/$self->{lang}-messages-js.po"; |
503 |
|
505 |
|
504 |
unless ( -f $pot ) { |
506 |
unless ( -f $pot && -f $js_pot ) { |
505 |
$self->extract_messages(); |
507 |
$self->extract_messages(); |
506 |
} |
508 |
} |
507 |
|
509 |
|
508 |
say "Create messages ($self->{lang})" if $self->{verbose}; |
510 |
say "Create messages ($self->{lang})" if $self->{verbose}; |
509 |
my $locale = $self->locale_name(); |
511 |
my $locale = $self->locale_name(); |
510 |
system "$self->{msginit} -i $pot -o $po -l $locale --no-translator"; |
512 |
system "$self->{msginit} -i $pot -o $po -l $locale --no-translator"; |
|
|
513 |
system "$self->{msginit} -i $js_pot -o $js_po -l $locale --no-translator"; |
511 |
|
514 |
|
512 |
# If msginit failed to correctly set Plural-Forms, set a default one |
515 |
# If msginit failed to correctly set Plural-Forms, set a default one |
513 |
system "$self->{sed} --in-place $po " |
516 |
system "$self->{sed} --in-place " |
514 |
. "--expression='s/Plural-Forms: nplurals=INTEGER; plural=EXPRESSION/Plural-Forms: nplurals=2; plural=(n != 1)/'"; |
517 |
. "--expression='s/Plural-Forms: nplurals=INTEGER; plural=EXPRESSION/Plural-Forms: nplurals=2; plural=(n != 1)/' " |
|
|
518 |
. "$po $js_po"; |
515 |
} |
519 |
} |
516 |
|
520 |
|
517 |
sub update_messages { |
521 |
sub update_messages { |
Lines 519-532
sub update_messages {
Link Here
|
519 |
|
523 |
|
520 |
my $pot = "$self->{domain}.pot"; |
524 |
my $pot = "$self->{domain}.pot"; |
521 |
my $po = "$self->{path_po}/$self->{lang}-messages.po"; |
525 |
my $po = "$self->{path_po}/$self->{lang}-messages.po"; |
|
|
526 |
my $js_pot = "$self->{domain}-js.pot"; |
527 |
my $js_po = "$self->{path_po}/$self->{lang}-messages-js.po"; |
522 |
|
528 |
|
523 |
unless ( -f $pot ) { |
529 |
unless ( -f $pot && -f $js_pot ) { |
524 |
$self->extract_messages(); |
530 |
$self->extract_messages(); |
525 |
} |
531 |
} |
526 |
|
532 |
|
527 |
if ( -f $po ) { |
533 |
if ( -f $po && -f $js_po ) { |
528 |
say "Update messages ($self->{lang})" if $self->{verbose}; |
534 |
say "Update messages ($self->{lang})" if $self->{verbose}; |
529 |
system "$self->{msgmerge} -U $po $pot"; |
535 |
system "$self->{msgmerge} -U $po $pot"; |
|
|
536 |
system "$self->{msgmerge} -U $js_po $js_pot"; |
530 |
} else { |
537 |
} else { |
531 |
$self->create_messages(); |
538 |
$self->create_messages(); |
532 |
} |
539 |
} |
Lines 638-644
sub extract_messages {
Link Here
|
638 |
. "-k__p:1c,2 -k__px:1c,2 -k__np:1c,2,3 -k__npx:1c,2,3 " |
645 |
. "-k__p:1c,2 -k__px:1c,2 -k__np:1c,2,3 -k__npx:1c,2,3 " |
639 |
. "-kN__ -kN__n:1,2 -kN__p:1c,2 -kN__np:1c,2,3"; |
646 |
. "-kN__ -kN__n:1,2 -kN__p:1c,2 -kN__np:1c,2,3"; |
640 |
my $xgettext_cmd = "$self->{xgettext} -L Perl $xgettext_common_args " |
647 |
my $xgettext_cmd = "$self->{xgettext} -L Perl $xgettext_common_args " |
641 |
. "-o $Bin/$self->{domain}-perl.pot -D $tempdir -D $intranetdir"; |
648 |
. "-o $Bin/$self->{domain}.pot -D $tempdir -D $intranetdir"; |
642 |
$xgettext_cmd .= " $_" foreach (@files_to_scan); |
649 |
$xgettext_cmd .= " $_" foreach (@files_to_scan); |
643 |
|
650 |
|
644 |
if (system($xgettext_cmd) != 0) { |
651 |
if (system($xgettext_cmd) != 0) { |
Lines 647-653
sub extract_messages {
Link Here
|
647 |
|
654 |
|
648 |
my @js_dirs = ( |
655 |
my @js_dirs = ( |
649 |
"$intranetdir/koha-tmpl/intranet-tmpl/prog/js", |
656 |
"$intranetdir/koha-tmpl/intranet-tmpl/prog/js", |
650 |
"$intranetdir/koha-tmpl/intranet-tmpl/prog/en/js", |
|
|
651 |
"$intranetdir/koha-tmpl/opac-tmpl/bootstrap/js", |
657 |
"$intranetdir/koha-tmpl/opac-tmpl/bootstrap/js", |
652 |
); |
658 |
); |
653 |
|
659 |
|
Lines 668-681
sub extract_messages {
Link Here
|
668 |
die "system call failed: $xgettext_cmd"; |
674 |
die "system call failed: $xgettext_cmd"; |
669 |
} |
675 |
} |
670 |
|
676 |
|
671 |
my $msgcat_cmd = "$self->{msgcat} --use-first -o $Bin/$self->{domain}.pot $Bin/$self->{domain}-perl.pot $Bin/$self->{domain}-js.pot"; |
|
|
672 |
if (system($msgcat_cmd) != 0) { |
673 |
die "system call failed: $msgcat_cmd"; |
674 |
} |
675 |
|
676 |
my $replace_charset_cmd = "$self->{sed} --in-place " . |
677 |
my $replace_charset_cmd = "$self->{sed} --in-place " . |
677 |
"$Bin/$self->{domain}.pot " . |
678 |
"--expression='s/charset=CHARSET/charset=UTF-8/' " . |
678 |
"--expression='s/charset=CHARSET/charset=UTF-8/'"; |
679 |
"$Bin/$self->{domain}.pot $Bin/$self->{domain}-js.pot"; |
679 |
if (system($replace_charset_cmd) != 0) { |
680 |
if (system($replace_charset_cmd) != 0) { |
680 |
die "system call failed: $replace_charset_cmd"; |
681 |
die "system call failed: $replace_charset_cmd"; |
681 |
} |
682 |
} |
Lines 688-703
sub install_messages {
Link Here
|
688 |
my $modir = "$self->{path_po}/$locale/LC_MESSAGES"; |
689 |
my $modir = "$self->{path_po}/$locale/LC_MESSAGES"; |
689 |
my $pofile = "$self->{path_po}/$self->{lang}-messages.po"; |
690 |
my $pofile = "$self->{path_po}/$self->{lang}-messages.po"; |
690 |
my $mofile = "$modir/$self->{domain}.mo"; |
691 |
my $mofile = "$modir/$self->{domain}.mo"; |
|
|
692 |
my $js_pofile = "$self->{path_po}/$self->{lang}-messages-js.po"; |
691 |
|
693 |
|
692 |
if ( not -f $pofile ) { |
694 |
unless ( -f $pofile && -f $js_pofile ) { |
693 |
$self->create_messages(); |
695 |
$self->create_messages(); |
694 |
} |
696 |
} |
695 |
say "Install messages ($locale)" if $self->{verbose}; |
697 |
say "Install messages ($locale)" if $self->{verbose}; |
696 |
make_path($modir); |
698 |
make_path($modir); |
697 |
system "$self->{msgfmt} -o $mofile $pofile"; |
699 |
system "$self->{msgfmt} -o $mofile $pofile"; |
698 |
|
700 |
|
699 |
my $js_locale_data = 'var json_locale_data = {"Koha":' . `$self->{po2json} $pofile` . '};'; |
701 |
my $js_locale_data = 'var json_locale_data = {"Koha":' . `$self->{po2json} $js_pofile` . '};'; |
700 |
my $progdir = $self->{context}->config('intrahtdocs') . '/prog'; |
702 |
my $progdir = $self->{context}->config('intrahtdocs') . '/prog'; |
|
|
703 |
mkdir "$progdir/$self->{lang}/js"; |
701 |
open my $fh, '>', "$progdir/$self->{lang}/js/locale_data.js"; |
704 |
open my $fh, '>', "$progdir/$self->{lang}/js/locale_data.js"; |
702 |
print $fh $js_locale_data; |
705 |
print $fh $js_locale_data; |
703 |
close $fh; |
706 |
close $fh; |
Lines 716-722
sub remove_pot {
Link Here
|
716 |
my $self = shift; |
719 |
my $self = shift; |
717 |
|
720 |
|
718 |
unlink "$Bin/$self->{domain}.pot"; |
721 |
unlink "$Bin/$self->{domain}.pot"; |
719 |
unlink "$Bin/$self->{domain}-perl.pot"; |
|
|
720 |
unlink "$Bin/$self->{domain}-js.pot"; |
722 |
unlink "$Bin/$self->{domain}-js.pot"; |
721 |
} |
723 |
} |
722 |
|
724 |
|
723 |
- |
|
|