diff options
author | Jakob Sack <mail@jakobsack.de> | 2013-07-07 21:51:24 +0400 |
---|---|---|
committer | Jakob Sack <mail@jakobsack.de> | 2013-07-07 21:51:24 +0400 |
commit | e13d1d0cf2548c172e3c670ef7fe1b35befbb755 (patch) | |
tree | 430c00bf59f53a72e01e8738b58b0ad7eb30b5d2 /l10n/l10n.pl | |
parent | 096d7674fc84777b8251cc42d88d6979a82b1ec0 (diff) |
Add possibility to read/write plural translations
Diffstat (limited to 'l10n/l10n.pl')
-rw-r--r-- | l10n/l10n.pl | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/l10n/l10n.pl b/l10n/l10n.pl index b07d6d686bc..8d13ec29a37 100644 --- a/l10n/l10n.pl +++ b/l10n/l10n.pl @@ -39,7 +39,7 @@ sub crawlFiles{ foreach my $i ( @files ){ next if substr( $i, 0, 1 ) eq '.'; next if $i eq 'l10n'; - + if( -d $dir.'/'.$i ){ push( @found, crawlFiles( $dir.'/'.$i )); } @@ -100,11 +100,17 @@ if( $task eq 'read' ){ foreach my $file ( @totranslate ){ next if $ignore{$file}; - my $keyword = ( $file =~ /\.js$/ ? 't:2' : 't'); + my $keywords = ''; + if( $file =~ /\.js$/ ){ + $keywords = '--keyword=t:2 --keyword=tp:2,3'; + } + else{ + $keywords = '--keyword=t --keyword=tp:1,2'; + } my $language = ( $file =~ /\.js$/ ? 'Python' : 'PHP'); my $joinexisting = ( -e $output ? '--join-existing' : ''); print " Reading $file\n"; - `xgettext --output="$output" $joinexisting --keyword=$keyword --language=$language "$file" --from-code=UTF-8 --package-version="5.0.0" --package-name="ownCloud Core" --msgid-bugs-address="translations\@owncloud.org"`; + `xgettext --output="$output" $joinexisting $keywords --language=$language "$file" --from-code=UTF-8 --package-version="5.0.0" --package-name="ownCloud Core" --msgid-bugs-address="translations\@owncloud.org"`; } chdir( $whereami ); } @@ -118,7 +124,7 @@ elsif( $task eq 'write' ){ print " Processing $app\n"; foreach my $language ( @languages ){ next if $language eq 'templates'; - + my $input = "${whereami}/$language/$app.po"; next unless -e $input; @@ -128,8 +134,18 @@ elsif( $task eq 'write' ){ my @strings = (); foreach my $string ( @{$array} ){ next if $string->msgid() eq '""'; - next if $string->msgstr() eq '""'; - push( @strings, $string->msgid()." => ".$string->msgstr()); + + # Do we use singular or plural? + if( defined( $string->msgstr_n() )){ + next if $string->msgstr_n()->{"0"} eq '""' || + $string->msgstr_n()->{"1"} eq '""'; + push( @strings, $string->msgid()." => ".$string->msgstr_n()->{"0"} ); + push( @strings, $string->msgid_plural()." => ".$string->msgstr_n()->{"1"} ); + } + else{ + next if $string->msgstr() eq '""'; + push( @strings, $string->msgid()." => ".$string->msgstr()); + } } next if $#strings == -1; # Skip empty files |