Lines 25-30
use C4::Context;
Link Here
|
25 |
use YAML::Syck qw( Dump LoadFile ); |
25 |
use YAML::Syck qw( Dump LoadFile ); |
26 |
use Locale::PO; |
26 |
use Locale::PO; |
27 |
use FindBin qw( $Bin ); |
27 |
use FindBin qw( $Bin ); |
|
|
28 |
use File::Path qw( make_path ); |
28 |
|
29 |
|
29 |
$YAML::Syck::ImplicitTyping = 1; |
30 |
$YAML::Syck::ImplicitTyping = 1; |
30 |
|
31 |
|
Lines 66-78
sub new {
Link Here
|
66 |
$self->{process} = "$Bin/tmpl_process3.pl " . ($verbose ? '' : '-q'); |
67 |
$self->{process} = "$Bin/tmpl_process3.pl " . ($verbose ? '' : '-q'); |
67 |
$self->{path_po} = "$Bin/po"; |
68 |
$self->{path_po} = "$Bin/po"; |
68 |
$self->{po} = { '' => $default_pref_po_header }; |
69 |
$self->{po} = { '' => $default_pref_po_header }; |
69 |
$self->{domain} = 'messages'; |
70 |
$self->{domain} = 'Koha'; |
70 |
$self->{cp} = `which cp`; |
71 |
$self->{cp} = `which cp`; |
71 |
$self->{msgmerge} = `which msgmerge`; |
72 |
$self->{msgmerge} = `which msgmerge`; |
|
|
73 |
$self->{msgfmt} = `which msgfmt`; |
72 |
$self->{xgettext} = `which xgettext`; |
74 |
$self->{xgettext} = `which xgettext`; |
73 |
$self->{sed} = `which sed`; |
75 |
$self->{sed} = `which sed`; |
74 |
chomp $self->{cp}; |
76 |
chomp $self->{cp}; |
75 |
chomp $self->{msgmerge}; |
77 |
chomp $self->{msgmerge}; |
|
|
78 |
chomp $self->{msgfmt}; |
76 |
chomp $self->{xgettext}; |
79 |
chomp $self->{xgettext}; |
77 |
chomp $self->{sed}; |
80 |
chomp $self->{sed}; |
78 |
|
81 |
|
Lines 466-484
sub create_tmpl {
Link Here
|
466 |
sub create_messages { |
469 |
sub create_messages { |
467 |
my $self = shift; |
470 |
my $self = shift; |
468 |
|
471 |
|
469 |
print "Create messages ($self->{lang})\n" if $self->{verbose}; |
472 |
my ($language, $country) = split /-/, $self->{lang}; |
|
|
473 |
my $locale = $language; |
474 |
if ($country) { |
475 |
$locale .= '_' . $country; |
476 |
} |
477 |
my $podir = "$self->{path_po}/$locale/LC_MESSAGES"; |
478 |
|
479 |
make_path($podir); |
480 |
say "Create messages ($locale)" if $self->{verbose}; |
470 |
system |
481 |
system |
471 |
"$self->{cp} $self->{domain}.pot " . |
482 |
"$self->{cp} $self->{domain}.pot " . |
472 |
"$self->{path_po}/$self->{lang}-$self->{domain}.po"; |
483 |
"$podir/$self->{domain}.po"; |
473 |
} |
484 |
} |
474 |
|
485 |
|
475 |
sub update_messages { |
486 |
sub update_messages { |
476 |
my $self = shift; |
487 |
my $self = shift; |
477 |
|
488 |
|
478 |
my $pofile = "$self->{path_po}/$self->{lang}-$self->{domain}.po"; |
489 |
my ($language, $country) = split /-/, $self->{lang}; |
479 |
print "Update messages ($self->{lang})\n" if $self->{verbose}; |
490 |
my $locale = $language; |
|
|
491 |
if ($country) { |
492 |
$locale .= '_' . $country; |
493 |
} |
494 |
my $podir = "$self->{path_po}/$locale/LC_MESSAGES"; |
495 |
my $pofile = "$podir/$self->{domain}.po"; |
496 |
|
497 |
say "Update messages ($locale)" if $self->{verbose}; |
480 |
if ( not -f $pofile ) { |
498 |
if ( not -f $pofile ) { |
481 |
print "File $pofile does not exist\n" if $self->{verbose}; |
499 |
say "File $pofile does not exist" if $self->{verbose}; |
482 |
$self->create_messages(); |
500 |
$self->create_messages(); |
483 |
} |
501 |
} |
484 |
system "$self->{msgmerge} -U $pofile $self->{domain}.pot"; |
502 |
system "$self->{msgmerge} -U $pofile $self->{domain}.pot"; |
Lines 506-513
sub extract_messages {
Link Here
|
506 |
} |
524 |
} |
507 |
} |
525 |
} |
508 |
|
526 |
|
509 |
my $xgettext_cmd = "$self->{xgettext} -L Perl --from-code=UTF-8 " . |
527 |
my $xgettext_cmd = "$self->{xgettext} -L Perl --from-code=UTF-8 " |
510 |
"-o $Bin/$self->{domain}.pot -D $intranetdir"; |
528 |
. "-k -k__ -k__x -k__n:1,2 -k__nx:1,2 -k__xn:1,2 -k__p:1c,2 " |
|
|
529 |
. "-k__px:1c,2 -k__np:1c,2,3 -k__npx:1c,2,3 -kN__ -kN__n:1,2 " |
530 |
. "-kN__p:1c,2 -kN__np:1c,2,3 " |
531 |
. "-o $Bin/$self->{domain}.pot -D $intranetdir"; |
511 |
$xgettext_cmd .= " $_" foreach (@files_to_scan); |
532 |
$xgettext_cmd .= " $_" foreach (@files_to_scan); |
512 |
|
533 |
|
513 |
if (system($xgettext_cmd) != 0) { |
534 |
if (system($xgettext_cmd) != 0) { |
Lines 522-533
sub extract_messages {
Link Here
|
522 |
die "system call failed: $replace_charset_cmd"; |
543 |
die "system call failed: $replace_charset_cmd"; |
523 |
} |
544 |
} |
524 |
} else { |
545 |
} else { |
525 |
print "No messages found\n" if $self->{verbose}; |
546 |
say "No messages found" if $self->{verbose}; |
526 |
return; |
547 |
return; |
527 |
} |
548 |
} |
528 |
return 1; |
549 |
return 1; |
529 |
} |
550 |
} |
530 |
|
551 |
|
|
|
552 |
sub install_messages { |
553 |
my ($self) = @_; |
554 |
|
555 |
my ($language, $country) = split /-/, $self->{lang}; |
556 |
my $locale = $language; |
557 |
if ($country) { |
558 |
$locale .= '_' . $country; |
559 |
} |
560 |
my $podir = "$self->{path_po}/$locale/LC_MESSAGES"; |
561 |
my $pofile = "$podir/$self->{domain}.po"; |
562 |
my $mofile = "$podir/$self->{domain}.mo"; |
563 |
|
564 |
say "Install messages ($locale)" if $self->{verbose}; |
565 |
if ( not -f $pofile ) { |
566 |
say "File $pofile does not exist" if $self->{verbose}; |
567 |
$self->create_messages(); |
568 |
} |
569 |
system "$self->{msgfmt} -o $mofile $pofile"; |
570 |
} |
571 |
|
531 |
sub remove_pot { |
572 |
sub remove_pot { |
532 |
my $self = shift; |
573 |
my $self = shift; |
533 |
|
574 |
|
Lines 539-544
sub install {
Link Here
|
539 |
return unless $self->{lang}; |
580 |
return unless $self->{lang}; |
540 |
$self->install_tmpl($files) unless $self->{pref_only}; |
581 |
$self->install_tmpl($files) unless $self->{pref_only}; |
541 |
$self->install_prefs(); |
582 |
$self->install_prefs(); |
|
|
583 |
$self->install_messages(); |
542 |
} |
584 |
} |
543 |
|
585 |
|
544 |
|
586 |
|
545 |
- |
|
|