Keep order when creating php files

This commit is contained in:
Jakob Sack 2011-06-20 22:22:17 +02:00
parent 3e74cca739
commit f72db005b5
1 changed files with 9 additions and 9 deletions

View 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