summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Sack <mail@jakobsack.de>2013-08-01 19:13:52 +0200
committerJakob Sack <mail@jakobsack.de>2013-08-01 19:13:52 +0200
commite064e53aa318bdfa43e62105e56f390f19a309f4 (patch)
tree1a58eaa39daae24777d79f3c3f2b09a4083f4e7b
parentfb976000914e291dce5d2ab61980149e8cec1a98 (diff)
downloadnextcloud-server-e064e53aa318bdfa43e62105e56f390f19a309f4.tar.gz
nextcloud-server-e064e53aa318bdfa43e62105e56f390f19a309f4.zip
Save the plural information given in po files
-rw-r--r--l10n/l10n.pl25
1 files changed, 20 insertions, 5 deletions
diff --git a/l10n/l10n.pl b/l10n/l10n.pl
index 9e5caa6badb..2a02e19c714 100644
--- a/l10n/l10n.pl
+++ b/l10n/l10n.pl
@@ -64,6 +64,16 @@ sub readIgnorelist{
return %ignore;
}
+sub getPluralInfo {
+ my( $info ) = @_;
+
+ # get string
+ $info =~ s/.*Plural-Forms: (.+)\\n.*/$1/;
+ $info =~ s/^(.*)\\n.*/$1/g;
+
+ return $info;
+}
+
my $task = shift( @ARGV );
my $place = '..';
@@ -132,11 +142,15 @@ elsif( $task eq 'write' ){
my $array = Locale::PO->load_file_asarray( $input );
# Create array
my @strings = ();
- foreach my $string ( @{$array} ){
- next if $string->msgid() eq '""';
+ my $plurals;
- # Do we use singular or plural?
- if( defined( $string->msgstr_n() )){
+ foreach my $string ( @{$array} ){
+ if( $string->msgid() eq '""' ){
+ # Translator information
+ $plurals = getPluralInfo( $string->msgstr());
+ }
+ elsif( defined( $string->msgstr_n() )){
+ # plural translations
my @variants = ();
my $identifier = $string->msgid()."::".$string->msgid_plural();
$identifier =~ s/"/_/g;
@@ -148,6 +162,7 @@ elsif( $task eq 'write' ){
push( @strings, "\"$identifier\" => array(".join(@variants, ",").")");
}
else{
+ # singular translations
next if $string->msgstr() eq '""';
push( @strings, $string->msgid()." => ".$string->msgstr());
}
@@ -158,7 +173,7 @@ elsif( $task eq 'write' ){
open( OUT, ">$language.php" );
print OUT "<?php \$TRANSLATIONS = array(\n";
print OUT join( ",\n", @strings );
- print OUT "\n);\n";
+ print OUT "\n); \$PLURAL_FORMS = \"$plurals\";\n";
close( OUT );
}
chdir( $whereami );