]> source.dussan.org Git - nextcloud-server.git/commitdiff
Keep order when creating php files
authorJakob Sack <kde@jakobsack.de>
Mon, 20 Jun 2011 20:22:17 +0000 (22:22 +0200)
committerJakob Sack <kde@jakobsack.de>
Mon, 20 Jun 2011 20:22:17 +0000 (22:22 +0200)
l10n/l10n.pl

index a5fab01a2fd5074fd9fab3716867583f8166f1aa..88abc821e950c7c8cf5167b67af2d528e8243ed2 100644 (file)
@@ -30,6 +30,10 @@ my $place = '..';
 
 die( "Usuage: l10n.pl task\ntask: read, write\n") unless $task && $place;
 
+# Our current position
+my $whereami = cwd();
+die( "Program must be executed in a l10n-folder called 'l10n'" ) unless $whereami =~ m/\/l10n$/;
+
 # Where are i18n-files?
 my @dirs = crawl( $place );
 
@@ -44,9 +48,6 @@ foreach my $i ( @files ){
        push( @languages, $i ) if -d $i && substr( $i, 0, 1 ) ne '.';
 }
 
-# Our current position
-my $whereami = cwd();
-
 if( $task eq 'read' ){
        foreach my $dir ( @dirs ){
                my @temp = split( /\//, $dir );
@@ -79,14 +80,13 @@ elsif( $task eq 'write' ){
                        my $input = "${whereami}/$language/$app.po";
                        next unless -e $input;
 
-                       my $hash = Locale::PO->load_file_ashash( $input );
-
+                       my $array = Locale::PO->load_file_asarray( $input );
                        # Create array
                        my @strings = ();
-                       foreach my $key ( keys( %{$hash} )){
-                               next if $key eq '""';
-                               next if $hash->{$key}->msgstr() eq '""';
-                               push( @strings, $hash->{$key}->msgid()." => ".$hash->{$key}->msgstr());
+                       foreach my $string ( @{$array} ){
+                               next if $string->msgid() eq '""';
+                               next if $string->msgstr() eq '""';
+                               push( @strings, $string->msgid()." => ".$string->msgstr());
                        }
                        next if $#strings == -1; # Skip empty files