aboutsummaryrefslogtreecommitdiffstats
path: root/dist-tools
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2019-08-26 18:48:02 +0200
committerMatthias Andree <matthias.andree@gmx.de>2019-08-26 19:07:34 +0200
commitcc22837a293d13e09fa6a510e370d7d03643c6d4 (patch)
treea0207ba75f891b60fd17893151182d5d01ae6931 /dist-tools
parent776945880512873055cc156a0344fbbac95b91ce (diff)
downloadfetchmail-cc22837a293d13e09fa6a510e370d7d03643c6d4.tar.gz
fetchmail-cc22837a293d13e09fa6a510e370d7d03643c6d4.tar.bz2
fetchmail-cc22837a293d13e09fa6a510e370d7d03643c6d4.zip
Helper script to commit PO updates to Git.
Diffstat (limited to 'dist-tools')
-rwxr-xr-xdist-tools/git-commit-po-updates.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/dist-tools/git-commit-po-updates.sh b/dist-tools/git-commit-po-updates.sh
new file mode 100755
index 00000000..1c2079fe
--- /dev/null
+++ b/dist-tools/git-commit-po-updates.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+set -eu
+
+# see if Perl has Carp::Always available:
+perl -MCarp::Always -e ''
+
+git diff -G ^.Project-Id-Version --name-only po/*.po \
+| while read pofile ; do
+ if ! cmd="$(perl -WT - "$pofile" <<'_EOF'
+use strict;
+use Carp::Always ();
+use warnings FATAL => 'uninitialized';
+my ($ver, $dat, $trl, $lang, $lcod, $found);
+
+while(<>)
+{
+ 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) {
+ $found = 1;
+ last;
+ }
+}
+
+if ($found) {
+ print "git commit --author '$trl' --date '$dat' -m 'Update <$lcod> $lang translation to $ver'"
+} else {
+ exit(1);
+}
+_EOF
+)"
+ then
+ echo >&2 "Parsing $pofile failed, skipping."
+ continue
+ fi
+ cmd="$cmd '$pofile'"
+ printf '+ %s\n' "$cmd"
+ eval "$cmd"
+done