aboutsummaryrefslogtreecommitdiffstats
path: root/l10n
diff options
context:
space:
mode:
authorJakob Sack <mail@jakobsack.de>2013-07-07 19:51:24 +0200
committerJakob Sack <mail@jakobsack.de>2013-07-07 19:51:24 +0200
commite13d1d0cf2548c172e3c670ef7fe1b35befbb755 (patch)
tree430c00bf59f53a72e01e8738b58b0ad7eb30b5d2 /l10n
parent096d7674fc84777b8251cc42d88d6979a82b1ec0 (diff)
downloadnextcloud-server-e13d1d0cf2548c172e3c670ef7fe1b35befbb755.tar.gz
nextcloud-server-e13d1d0cf2548c172e3c670ef7fe1b35befbb755.zip
Add possibility to read/write plural translations
Diffstat (limited to 'l10n')
-rw-r--r--l10n/l10n.pl28
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