Allow several plural forms in l10n php files
This commit is contained in:
parent
4e214883d6
commit
18fc22b52b
17
l10n/l10n.pl
17
l10n/l10n.pl
|
@ -102,10 +102,10 @@ if( $task eq 'read' ){
|
||||||
next if $ignore{$file};
|
next if $ignore{$file};
|
||||||
my $keywords = '';
|
my $keywords = '';
|
||||||
if( $file =~ /\.js$/ ){
|
if( $file =~ /\.js$/ ){
|
||||||
$keywords = '--keyword=t:2 --keyword=tp:2,3';
|
$keywords = '--keyword=t:2 --keyword=n:2,3';
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$keywords = '--keyword=t --keyword=tp:1,2';
|
$keywords = '--keyword=t --keyword=n:1,2';
|
||||||
}
|
}
|
||||||
my $language = ( $file =~ /\.js$/ ? 'Python' : 'PHP');
|
my $language = ( $file =~ /\.js$/ ? 'Python' : 'PHP');
|
||||||
my $joinexisting = ( -e $output ? '--join-existing' : '');
|
my $joinexisting = ( -e $output ? '--join-existing' : '');
|
||||||
|
@ -137,10 +137,15 @@ elsif( $task eq 'write' ){
|
||||||
|
|
||||||
# Do we use singular or plural?
|
# Do we use singular or plural?
|
||||||
if( defined( $string->msgstr_n() )){
|
if( defined( $string->msgstr_n() )){
|
||||||
next if $string->msgstr_n()->{"0"} eq '""' ||
|
my @variants = ();
|
||||||
$string->msgstr_n()->{"1"} eq '""';
|
my $identifier = $string->msgid()."::".$string->msgid_plural()
|
||||||
push( @strings, $string->msgid()." => ".$string->msgstr_n()->{"0"} );
|
$identifier =~ s/"/_/g;
|
||||||
push( @strings, $string->msgid_plural()." => ".$string->msgstr_n()->{"1"} );
|
|
||||||
|
foreach my $variant ( sort { $a <=> $b} keys( %{$string->msgstr_n()} )){
|
||||||
|
push( @variants, $string->msgstr_n()->{$variant} );
|
||||||
|
}
|
||||||
|
|
||||||
|
push( @strings, "\"$identifier\" => array(".join(@variants, ",").")";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
next if $string->msgstr() eq '""';
|
next if $string->msgstr() eq '""';
|
||||||
|
|
Loading…
Reference in New Issue