|
Lines 4-19
use Modern::Perl;
Link Here
|
| 4 |
|
4 |
|
| 5 |
use File::Slurp; |
5 |
use File::Slurp; |
| 6 |
use File::Temp qw(tempdir); |
6 |
use File::Temp qw(tempdir); |
| 7 |
use FindBin qw($Bin); |
7 |
use FindBin qw($Bin); |
| 8 |
use Locale::PO; |
8 |
use Locale::PO; |
| 9 |
use Test::More tests => 43; |
9 |
use Test::More tests => 43; |
| 10 |
|
10 |
|
| 11 |
my $tempdir = tempdir(CLEANUP => 1); |
11 |
my $tempdir = tempdir( CLEANUP => 1 ); |
| 12 |
|
12 |
|
| 13 |
write_file("$tempdir/files", "$Bin/sample.tt"); |
13 |
write_file( "$tempdir/files", "$Bin/sample.tt" ); |
| 14 |
|
14 |
|
| 15 |
my $xgettext_cmd = "$Bin/../../../../misc/translator/xgettext-tt2 --from-code=UTF-8 " |
15 |
my $xgettext_cmd = |
| 16 |
. "-o $tempdir/Koha.pot -f $tempdir/files"; |
16 |
"$Bin/../../../../misc/translator/xgettext-tt2 --from-code=UTF-8 " . "-o $tempdir/Koha.pot -f $tempdir/files"; |
| 17 |
|
17 |
|
| 18 |
system($xgettext_cmd); |
18 |
system($xgettext_cmd); |
| 19 |
my $pot = Locale::PO->load_file_asarray("$tempdir/Koha.pot"); |
19 |
my $pot = Locale::PO->load_file_asarray("$tempdir/Koha.pot"); |
|
Lines 26-55
my @expected = (
Link Here
|
| 26 |
msgid => '"hello {name}"', |
26 |
msgid => '"hello {name}"', |
| 27 |
}, |
27 |
}, |
| 28 |
{ |
28 |
{ |
| 29 |
msgid => '"item"', |
29 |
msgid => '"item"', |
| 30 |
msgid_plural => '"items"', |
30 |
msgid_plural => '"items"', |
| 31 |
}, |
31 |
}, |
| 32 |
{ |
32 |
{ |
| 33 |
msgid => '"{count} item"', |
33 |
msgid => '"{count} item"', |
| 34 |
msgid_plural => '"{count} items"', |
34 |
msgid_plural => '"{count} items"', |
| 35 |
}, |
35 |
}, |
| 36 |
{ |
36 |
{ |
| 37 |
msgid => '"hello"', |
37 |
msgid => '"hello"', |
| 38 |
msgctxt => '"context"', |
38 |
msgctxt => '"context"', |
| 39 |
}, |
39 |
}, |
| 40 |
{ |
40 |
{ |
| 41 |
msgid => '"hello {name}"', |
41 |
msgid => '"hello {name}"', |
| 42 |
msgctxt => '"context"', |
42 |
msgctxt => '"context"', |
| 43 |
}, |
43 |
}, |
| 44 |
{ |
44 |
{ |
| 45 |
msgid => '"item"', |
45 |
msgid => '"item"', |
| 46 |
msgid_plural => '"items"', |
46 |
msgid_plural => '"items"', |
| 47 |
msgctxt => '"context"', |
47 |
msgctxt => '"context"', |
| 48 |
}, |
48 |
}, |
| 49 |
{ |
49 |
{ |
| 50 |
msgid => '"{count} item"', |
50 |
msgid => '"{count} item"', |
| 51 |
msgid_plural => '"{count} items"', |
51 |
msgid_plural => '"{count} items"', |
| 52 |
msgctxt => '"context"', |
52 |
msgctxt => '"context"', |
| 53 |
}, |
53 |
}, |
| 54 |
{ |
54 |
{ |
| 55 |
msgid => '"status is {status}"', |
55 |
msgid => '"status is {status}"', |
|
Lines 67-83
my @expected = (
Link Here
|
| 67 |
msgid => '"with filter"', |
67 |
msgid => '"with filter"', |
| 68 |
}, |
68 |
}, |
| 69 |
{ |
69 |
{ |
| 70 |
msgid => '"filter singular"', |
70 |
msgid => '"filter singular"', |
| 71 |
msgid_plural => '"filter plural"', |
71 |
msgid_plural => '"filter plural"', |
| 72 |
}, |
72 |
}, |
| 73 |
); |
73 |
); |
| 74 |
|
74 |
|
| 75 |
for (my $i = 0; $i < @expected; $i++) { |
75 |
for ( my $i = 0 ; $i < @expected ; $i++ ) { |
| 76 |
for my $key (qw(msgid msgid_plural msgctxt)) { |
76 |
for my $key (qw(msgid msgid_plural msgctxt)) { |
| 77 |
my $expected = $expected[$i]->{$key}; |
77 |
my $expected = $expected[$i]->{$key}; |
| 78 |
my $expected_str = defined $expected ? $expected : 'not defined'; |
78 |
my $expected_str = defined $expected ? $expected : 'not defined'; |
| 79 |
is($pot->[$i + 1]->$key, $expected, "$i: $key is $expected_str"); |
79 |
is( $pot->[ $i + 1 ]->$key, $expected, "$i: $key is $expected_str" ); |
| 80 |
} |
80 |
} |
| 81 |
} |
81 |
} |
| 82 |
|
82 |
|
| 83 |
is(@$pot, 1 + @expected, "No more strings than expected"); |
83 |
is( @$pot, 1 + @expected, "No more strings than expected" ); |
| 84 |
- |
|
|