X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=build%2Fi18n-update.pl;h=16b82e8dddc126d4223f251dfac42bd2794605f8;hb=0b0df324bfdcf4bb9870a8edd82567f4091d6ff1;hp=c41b039b7d0a4f37b51cd9421425c6ba58c94ad7;hpb=1f3666f7225eb33d932a7ae067dbca05e57ad9ca;p=project%2Fluci.git diff --git a/build/i18n-update.pl b/build/i18n-update.pl index c41b039b7d..16b82e8ddd 100755 --- a/build/i18n-update.pl +++ b/build/i18n-update.pl @@ -5,6 +5,22 @@ my $source = shift @ARGV; my $pattern = shift @ARGV || '*.po'; +sub fixup_header_order +{ + my $file = shift || return; + local $/; + + open P, "< $file" || die "open(): $!"; + my $data = readline P; + close P; + + $data =~ s/("Language-Team: .*?\\n"\n)(.+?)("Language: .*?\\n"\n)/$1$3$2/s; + + open P, "> $file" || die "open(): $!"; + print P $data; + close P; +} + if( open F, "find $source -type f -name '$pattern' |" ) { while( chomp( my $file = readline F ) ) @@ -14,7 +30,8 @@ if( open F, "find $source -type f -name '$pattern' |" ) if( -f "$source/templates/$basename.pot" ) { printf "Updating %-40s", $file; - system("msgmerge", "-U", $file, "$source/templates/$basename.pot"); + system("msgmerge", "-U", "-N", $file, "$source/templates/$basename.pot"); + fixup_header_order($file); } }