Skip to content
Snippets Groups Projects
Commit 62a85951 authored by Matthias Aßhauer's avatar Matthias Aßhauer
Browse files

add a script to set priorites for weblate


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: default avatarMatthias Aßhauer <mha1993@live.de>
parent 92e80193
No related branches found
No related tags found
No related merge requests found
#!/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])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment