diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2019-09-05 22:58:35 +0200 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2019-09-05 22:58:35 +0200 |
commit | 6b70292d33eae6df4882704ebc406953b5c1b38f (patch) | |
tree | 6b2d5319610448925e0eb4bd052d2d70eaf2931e | |
parent | 76f5f37041203038336844c3072a12bf9c19c7e2 (diff) | |
download | fetchmail-6b70292d33eae6df4882704ebc406953b5c1b38f.tar.gz fetchmail-6b70292d33eae6df4882704ebc406953b5c1b38f.tar.bz2 fetchmail-6b70292d33eae6df4882704ebc406953b5c1b38f.zip |
Decode .po's author name to locale according to Content-Type header.
-rwxr-xr-x | dist-tools/git-commit-po-updates.sh | 22 |
1 files changed, 14 insertions, 8 deletions
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); } |