From 6b70292d33eae6df4882704ebc406953b5c1b38f Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Thu, 5 Sep 2019 22:58:35 +0200 Subject: Decode .po's author name to locale according to Content-Type header. --- dist-tools/git-commit-po-updates.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'dist-tools') diff --git a/dist-tools/git-commit-po-updates.sh b/dist-tools/git-commit-po-updates.sh index 13e2bf5c..8f633d88 100755 --- a/dist-tools/git-commit-po-updates.sh +++ b/dist-tools/git-commit-po-updates.sh @@ -31,27 +31,33 @@ done git diff -G ^.Project-Id-Version --name-only po/*.po \ | while read pofile ; do if ! cmd="$(perl -WT - "$pofile" <<'_EOF' +use Encode::Locale; +use Encode; use strict; use Carp::Always (); use warnings FATAL => 'uninitialized'; -my ($ver, $dat, $trl, $lang, $lcod, $found); +my ($ver, $dat, $trl, $lang, $lcod, $cset, $found); while(<>) { - if (/^"Project-Id-Version: (.+)\\n"/) { $ver=$1 }; - if (/^"PO-Revision-Date: (.+)\\n"/) { $dat=$1 }; - if (/^"Last-Translator: (.+)\\n"/) { $trl=$1 }; + if (/^"Project-Id-Version: (.+)\\n"/) { $ver=$1; }; + if (/^"PO-Revision-Date: (.+)\\n"/) { $dat=$1; }; + if (/^"Last-Translator: (.+)\\n"/) { $trl=$1; }; if (/^"Language-Team: ([^<]+?)\s+<.*>\\n"/) - { $lang=$1 }; - if (/^"Language: (.+)\\n"/) { $lcod=$1 }; - if ($ver and $dat and $trl and $lang and $lcod) { + { $lang=$1; }; + if (/^"Language: (.+)\\n"/) { $lcod=$1; }; + if (/^"Content-Type: text\/plain; charset=(.+)\\n"/) + { $cset = $1; }; + if ($ver and $dat and $trl and $lang and $lcod and $cset) { $found = 1; last; } } +$trl = Encode::decode($cset, $trl); + 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 { exit(1); } -- cgit v1.2.3