Commit 6b70292d authored by Matthias Andree's avatar Matthias Andree

Decode .po's author name to locale according to Content-Type header.

parent 76f5f370
...@@ -31,27 +31,33 @@ done ...@@ -31,27 +31,33 @@ done
git diff -G ^.Project-Id-Version --name-only po/*.po \ git diff -G ^.Project-Id-Version --name-only po/*.po \
| while read pofile ; do | while read pofile ; do
if ! cmd="$(perl -WT - "$pofile" <<'_EOF' if ! cmd="$(perl -WT - "$pofile" <<'_EOF'
use Encode::Locale;
use Encode;
use strict; use strict;
use Carp::Always (); use Carp::Always ();
use warnings FATAL => 'uninitialized'; use warnings FATAL => 'uninitialized';
my ($ver, $dat, $trl, $lang, $lcod, $found); my ($ver, $dat, $trl, $lang, $lcod, $cset, $found);
while(<>) while(<>)
{ {
if (/^"Project-Id-Version: (.+)\\n"/) { $ver=$1 }; if (/^"Project-Id-Version: (.+)\\n"/) { $ver=$1; };
if (/^"PO-Revision-Date: (.+)\\n"/) { $dat=$1 }; if (/^"PO-Revision-Date: (.+)\\n"/) { $dat=$1; };
if (/^"Last-Translator: (.+)\\n"/) { $trl=$1 }; if (/^"Last-Translator: (.+)\\n"/) { $trl=$1; };
if (/^"Language-Team: ([^<]+?)\s+<.*>\\n"/) if (/^"Language-Team: ([^<]+?)\s+<.*>\\n"/)
{ $lang=$1 }; { $lang=$1; };
if (/^"Language: (.+)\\n"/) { $lcod=$1 }; if (/^"Language: (.+)\\n"/) { $lcod=$1; };
if ($ver and $dat and $trl and $lang and $lcod) { if (/^"Content-Type: text\/plain; charset=(.+)\\n"/)
{ $cset = $1; };
if ($ver and $dat and $trl and $lang and $lcod and $cset) {
$found = 1; $found = 1;
last; last;
} }
} }
$trl = Encode::decode($cset, $trl);
if ($found) { if ($found) {
print "git commit --author '$trl' --date '$dat' -m 'Update <$lcod> $lang translation to $ver'" print Encode::encode(locale => "git commit --author '$trl' --date '$dat' -m 'Update <$lcod> $lang translation to $ver'", Encode::FB_CROAK);
} else { } else {
exit(1); exit(1);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment