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

pre-translate-po: allow automatic translations of simple recurring phrases

parent e827f562
No related branches found
No related tags found
No related merge requests found
EN_SOURCES = $(wildcard en/*.txt)
LANGUAGE_PO = $(wildcard po/*.po)
LANGUAGE_PO = $(wildcard po/documentation.*.po)
ALL_LANGUAGES = $(subst po/documentation.,,$(subst .po,,$(LANGUAGE_PO)))
L10N_BUILD_TARGETS = all man html install doc-l10n install-l10n install-txt
......
# Recurring German translations for Regex Search & Replace in Git Man pages.
# Copyright (C) 2019 Free Software Foundation, Inc.
# This file is distributed under the same license as the Git package.
# Matthias Aßhauer <mha1993@live.de>, 2019
msgid "(--[a-zA-Z-]+\[?[=\s]<)path(>\]?)"
msgstr "\1Pfad\2"
msgid "(-{1,2}[a-zA-Z-]+?[=\s]<)file(>)"
msgstr "\1Datei\2"
msgid "(-{1,2}[a-zA-Z-]*?\[?[=\s]?<)num(>\]?)"
msgstr "\1Anz\2"
msgid "(-{1,2}[a-zA-Z-]+?\[?[=\s]<)pattern(>\]?)"
msgstr "\1Muster\2"
msgid "(--[a-zA-Z-]+?=<)glob-pattern(>)"
msgstr "\1Glob-Muster\2"
#~ msgid "release notes for ((link:RelNotes/[0-9.]+.txt\[[0-9.]+\][.,]?\s*)+)."
#~ msgstr "Versionshinweise für \1."
#~ msgid "(link:v[0-9.]+/git\.html\[)documentation for release ([0-9.]+\])"
#~ msgstr "\1Dokumentation für Version \2."
......@@ -4,9 +4,12 @@ import polib
import re
import sys
def main (f):
def main (f,d=None):
po = polib.pofile(f, wrapwidth=0)
if not d is None:
pod=polib.pofile(d)
for entry in po:
if (re.fullmatch(r'-[-a-z0-9[\]]+', entry.msgid)) \
or re.fullmatch(r'((linkgit:)?(git[-a-z0-9[\]]+|mail)(\[[157]\]|\([157]\))(,|;)?(\n| )?)+', entry.msgid) \
......@@ -16,12 +19,23 @@ def main (f):
entry.flags.append("ignore-same")
flags = sorted(set(entry.flags))
entry.flags = list(flags)
remove_fuzzy(entry)
elif not d is None:
for entryd in pod:
if re.fullmatch(entryd.msgid, entry.msgid):
entry.msgstr = re.sub(entryd.msgid, entryd.msgstr, entry.msgid)
remove_fuzzy(entry)
po.save(f)
def remove_fuzzy (entry):
if 'fuzzy' in entry.flags:
entry.flags.remove('fuzzy')
entry.previous_msgid = None
po.save(f)
if __name__ == '__main__':
if len(sys.argv)>1:
if len(sys.argv)>2:
main(sys.argv[1], sys.argv[2])
elif 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