X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=build%2Fi18n-update.pl;fp=build%2Fi18n-update.pl;h=16b82e8dddc126d4223f251dfac42bd2794605f8;hp=0dd213a5356624a0e7291b3fc89574c6d97bb224;hb=0b0df324bfdcf4bb9870a8edd82567f4091d6ff1;hpb=4f5638af1d8dfbfba0d2fc1b5919a20f7835a26d diff --git a/build/i18n-update.pl b/build/i18n-update.pl index 0dd213a53..16b82e8dd 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 ) ) @@ -15,6 +31,7 @@ if( open F, "find $source -type f -name '$pattern' |" ) { printf "Updating %-40s", $file; system("msgmerge", "-U", "-N", $file, "$source/templates/$basename.pot"); + fixup_header_order($file); } }