summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKarel Zak2016-05-25 15:28:42 +0200
committerKarel Zak2016-05-25 15:28:42 +0200
commit5d25b7814faf3272887d7e6dae82438fb084f2be (patch)
treec962400fd2d2a15e253dd240681e0cc6df1dcfc9 /tools
parentlibblkid: improve debug messages (diff)
downloadkernel-qcow2-util-linux-5d25b7814faf3272887d7e6dae82438fb084f2be.tar.gz
kernel-qcow2-util-linux-5d25b7814faf3272887d7e6dae82438fb084f2be.tar.xz
kernel-qcow2-util-linux-5d25b7814faf3272887d7e6dae82438fb084f2be.zip
tools: add script to load .po from translationproject.org
I use it for years, let's keep it in the repository. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/git-tp-sync58
1 files changed, 58 insertions, 0 deletions
diff --git a/tools/git-tp-sync b/tools/git-tp-sync
new file mode 100755
index 000000000..c2e2d8d8f
--- /dev/null
+++ b/tools/git-tp-sync
@@ -0,0 +1,58 @@
+#!/bin/bash
+#
+# git-tp-sync - downloads the latest PO files from translationproject.org
+# and commits changes to your GIT repository.
+#
+# Features:
+# - commit per PO file (no more huge commits for all .po files)
+# - the commit "Author:" field is set according to the Last-Translator
+#
+# Copyright (C) 2007-2016 Karel Zak <kzak@redhat.com>
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+PROJECT="util-linux"
+if [ -n "$1" ]; then
+ while (( "$#" )); do
+ if [ -n "$1" ]; then
+ rsync -Lrtvz rsync://translationproject.org/tp/latest/$PROJECT/$1.po po
+ fi
+ shift
+ done
+else
+ rsync -Lrtvz rsync://translationproject.org/tp/latest/$PROJECT/ po
+fi
+
+PO_NEW=$(git ls-files -o | gawk '/po\/[[:alpha:]_\-]*\.po/ { sub("po/", ""); print $0; }' | sort)
+PO_MOD=$(git ls-files -m | gawk '/po\/[[:alpha:]_\-]*\.po/ { sub("po/", ""); print $0; }' | sort)
+
+function get_author {
+ echo $(gawk 'BEGIN { FS=": " } /Last-Translator/ { sub("\\\\n\"", ""); print $2 }' "$1")
+}
+
+function do_commit {
+ local POFILE="$1"
+ local MSG="$2"
+ local AUTHOR=$(get_author "$POFILE")
+
+ git commit --author "$AUTHOR" -m "$MSG" "$POFILE"
+}
+
+for f in $PO_MOD; do
+ do_commit "po/$f" "po: update $f (from translationproject.org)"
+done
+
+for f in $PO_NEW; do
+ git add "po/$f"
+ do_commit "po/$f" "po: add $f (from translationproject.org)"
+done
+