From 62a85951cab7a7c8e67fd1d26e8df559e737bca3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= <mha1993@live.de>
Date: Mon, 19 Aug 2019 21:18:09 +0200
Subject: [PATCH] add a script to set priorites for weblate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The default priority in weblate is 100. These priorities are based on the categorisation
of commands on git-scm.com/docs. This closes jnavila/git-manpages-l10n#21.

Signed-off-by: Matthias Aíš©hauer <mha1993@live.de>
---
 scripts/set-priorities | 67 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100755 scripts/set-priorities

diff --git a/scripts/set-priorities b/scripts/set-priorities
new file mode 100755
index 0000000..ee31d9b
--- /dev/null
+++ b/scripts/set-priorities
@@ -0,0 +1,67 @@
+#!/usr/bin/python3
+
+import polib
+import sys
+
+SECTIONS = {300: ["en/git-init.txt",
+                  "en/git-clone.txt",
+                  "en/urls.txt",
+                  "en/git-add.txt"],
+            280: ["en/git-status.txt",
+                  "en/git-diff.txt",
+                  "en/diff-options.txt",
+                  "en/diff-format.txt",
+                  "en/git-commit.txt",
+                  "en/date-formats.txt",
+                  "en/i18n.txt",
+                  "en/git-reset.txt",
+                  "en/git-rm.txt",
+                  "en/git-mv.txt"],
+            260: ["en/git-show.txt",
+                  "en/pretty-options.txt",
+                  "en/pretty-formats.txt",
+                  "en/diff-generate-patch.txt",
+                  "en/git-log.txt",
+                  "en/line-range-format",
+                  "en/rev-list-options.txt",
+                  "en/git-shortlog.txt",
+                  "en/mailmap.txt",
+                  "en/git-describe.txt"],
+            240: ["en/git-branch.txt",
+                  "en/git-checkout.txt",
+                  "en/git-merge.txt",
+                  "en/merge-options.txt",
+                  "en/merge-strategies.txt",
+                  "en/config/merge.txt",
+                  "en/config/fmt-merge-msg.txt",
+                  "en/mergetools-merge.txt",
+                  "en/git-mergetool.txt",
+                  "en/git-stash.txt",
+                  "en/git-tag.txt",
+                  "en/git-worktree.txt"],
+            220: ["en/git-fetch.txt",
+                  "en/fetch-options.txt",
+                  "en/pull-fetch-param.txt",
+                  "en/urls-remotes.txt",
+                  "en/transfer-data-leaks.txt",
+                  "en/git-pull.txt",
+                  "en/git-push.txt",
+                  "en/git-remote.txt",
+                  "en/git-submodule.txt"]
+            }
+
+def main (f):
+    po = polib.pofile(f, wrapwidth=0)
+    priorities = dict((source, section) for section in SECTIONS for source in SECTIONS[section])
+    for entry in po:
+      if not entry.obsolete:
+        flags = [f for f in entry.flags if not f.startswith("priority:")]
+        p = max(priorities.get(filename) or 100 for (filename,_) in entry.occurrences)
+        flags.append("priority:{}".format(p))
+        entry.flags = flags
+    po.save(f)
+
+
+if __name__ == '__main__':
+    if len(sys.argv)>1:
+        main(sys.argv[1])
-- 
GitLab