View | Details | Raw Unified | Return to bug 26547
Collapse All | Expand All

(-)a/misc/devel/update-pref-po-file.pl (-1 / +41 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use Locale::PO;
5
6
foreach my $filename (@ARGV) {
7
    my $pos = Locale::PO->load_file_asarray($filename);
8
9
    foreach my $po (@$pos) {
10
        my $msgid = $po->dequote($po->msgid);
11
12
        if ($msgid =~ /^([^#]+)#([^#]*)# (.*)$/) {
13
            my ($file, $pref, $message) = ($1, $2, $3);
14
            my @comments = split /\n/, $po->comment;
15
            my $comment = $comments[0];
16
            my $context = $pref ? sprintf('%s > %s', $comment, $pref) : $comment;
17
            $po->msgctxt($context);
18
            $po->comment($context);
19
            $po->msgid($message);
20
            $po->reference(sprintf('koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/%s', $file));
21
        } elsif ($msgid =~ /^(\w+\.pref)$/) {
22
            my $file = $1;
23
            $po->msgid($po->comment);
24
            $po->comment(undef);
25
            $po->reference(sprintf('koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/%s', $file));
26
        } elsif ($msgid =~ /^(\w+\.pref) (.*)$/) {
27
            my ($file, $message) = ($1, $2);
28
            my $context = $po->comment =~ s/^([^>]+) >.*/$1/r;
29
            $po->msgctxt($context);
30
            $po->comment($context);
31
            $po->msgid($message);
32
            $po->reference(sprintf('koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/%s', $file));
33
        } elsif ($msgid eq '') {
34
            # This is the PO header, nothing to do here
35
        } else {
36
            warn sprintf("WARN: The PO entry at %s:%d has not been updated\n", $filename, $po->loaded_line_number);
37
        }
38
    }
39
40
    Locale::PO->save_file_fromarray($filename, $pos);
41
}

Return to bug 26547