mirror of
https://github.com/etlegacy/LegacyTransifexBot.git
synced 2025-02-16 17:11:11 +00:00
prfromtransifex.py didn't add new translations to resource files.
This commit is contained in:
parent
6284dd66b3
commit
7d4ab39591
2 changed files with 52 additions and 16 deletions
|
@ -41,19 +41,37 @@ body = New translation updates available from transifex
|
||||||
; %(minpercent)s See transifex.minpercent above
|
; %(minpercent)s See transifex.minpercent above
|
||||||
; %(langcount)d Number of languages matched with given settings
|
; %(langcount)d Number of languages matched with given settings
|
||||||
commit = Transifex translation update
|
commit = Transifex translation update
|
||||||
|
|
||||||
Mode: %(mode)s
|
Mode: %(mode)s
|
||||||
Minimum percent translated: %(minpercent)s
|
Minimum percent translated: %(minpercent)s
|
||||||
Matched %(langcount)d languages
|
Matched %(langcount)d languages
|
||||||
|
|
||||||
[misc]
|
[misc]
|
||||||
; File to store language bookkeeping data in
|
; pri file to store language bookkeeping data in
|
||||||
; Will be re-written and commited to the repository
|
; Will be re-written and commited to the repository
|
||||||
; if changes occur.
|
; if changes occur.
|
||||||
file = src/mumble/translations.pri
|
prifile = src/mumble/translations.pri
|
||||||
; Template to generate file from, available variables $(files)s
|
; Template to generate file from, available variables $(files)s
|
||||||
; for a space separated list of all files.
|
; for a space separated list of all files.
|
||||||
template = # Do not change manually
|
pritemplate = # Do not change manually
|
||||||
# Autogenerated by mumble transifex bot
|
# Autogenerated by mumble transifex bot
|
||||||
TRANSLATIONS = %(files)s
|
TRANSLATIONS = %(files)s
|
||||||
|
|
||||||
|
; qtc file to store language bookkeeping data in
|
||||||
|
; Will be re-written and commited to the repository
|
||||||
|
; if changes occur.
|
||||||
|
qrcfile = src/mumble/mumble_translations.qrc
|
||||||
|
; Template to generate file from, available variables $(files)s
|
||||||
|
; for a space separated list of all files.
|
||||||
|
qrctemplate = <!DOCTYPE RCC><RCC version="1.0">
|
||||||
|
<!--
|
||||||
|
Do not change manually
|
||||||
|
Autogenerated by mumble transifex bot
|
||||||
|
-->
|
||||||
|
<qresource>
|
||||||
|
%(files)s
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
||||||
|
|
||||||
; Space separated translation files not retrieved from transifex
|
; Space separated translation files not retrieved from transifex
|
||||||
additionaltsfiles = mumble_en.ts
|
additionaltsfiles = mumble_en.ts
|
|
@ -116,8 +116,10 @@ if __name__ == "__main__":
|
||||||
pr_body = cfg.get('pullrequest', 'body')
|
pr_body = cfg.get('pullrequest', 'body')
|
||||||
pr_commit = cfg.get('pullrequest', 'commit')
|
pr_commit = cfg.get('pullrequest', 'commit')
|
||||||
|
|
||||||
translationsfile = cfg.get('misc', 'file')
|
prifile = cfg.get('misc', 'prifile')
|
||||||
translationstemplate = cfg.get('misc', 'template')
|
pritemplate = cfg.get('misc', 'pritemplate')
|
||||||
|
qrcfile = cfg.get('misc', 'qrcfile')
|
||||||
|
qrctemplate = cfg.get('misc', 'qrctemplate')
|
||||||
additionaltsfiles = cfg.get('misc', 'additionaltsfiles')
|
additionaltsfiles = cfg.get('misc', 'additionaltsfiles')
|
||||||
|
|
||||||
if args.setup or not os.path.exists(wr_path):
|
if args.setup or not os.path.exists(wr_path):
|
||||||
|
@ -161,22 +163,38 @@ if __name__ == "__main__":
|
||||||
debug(git["reset", remote + "/" + branch, "--hard"]())
|
debug(git["reset", remote + "/" + branch, "--hard"]())
|
||||||
info("Cleaning repository")
|
info("Cleaning repository")
|
||||||
debug(git["clean", "-f", "-x", "-d"]())
|
debug(git["clean", "-f", "-x", "-d"]())
|
||||||
info("Pulling translations")
|
|
||||||
|
|
||||||
|
info("Pulling translations")
|
||||||
txout = tx["pull", "-f", "-a", "--mode=" + mode, "--minimum-perc=" + minpercent]()
|
txout = tx["pull", "-f", "-a", "--mode=" + mode, "--minimum-perc=" + minpercent]()
|
||||||
debug(txout)
|
debug(txout)
|
||||||
|
|
||||||
tfilepath = os.path.join(wr_path, translationsfile)
|
# Add all .ts files tx pull got to repo
|
||||||
info("Updating translations listing file '%s'", tfilepath)
|
|
||||||
paths, files = zip(*re.findall(r"^\s->\s[\w_]+:\s([\w/\_]+/([\w_]+\.ts))$", txout, flags=re.MULTILINE))
|
paths, files = zip(*re.findall(r"^\s->\s[\w_]+:\s([\w/\_]+/([\w_]+\.ts))$", txout, flags=re.MULTILINE))
|
||||||
debug(git["add"](*paths))
|
debug(git["add"](*paths))
|
||||||
translations = additionaltsfiles + " " + (" ".join(sorted(files)))
|
|
||||||
|
|
||||||
with open(tfilepath, "w") as f:
|
# Add additional ts files not in control of transifex (e.g. English source translation)
|
||||||
f.write(translationstemplate % {'files': translations})
|
files = list(files)
|
||||||
|
files.extend(additionaltsfiles.split(" "))
|
||||||
|
files.sort()
|
||||||
|
|
||||||
debug(git["add"](tfilepath))
|
# Write pri file listing ts files for build
|
||||||
|
prifilepath = os.path.join(wr_path, prifile)
|
||||||
|
info("Updating translations listing file '%s'", prifilepath)
|
||||||
|
tsfiles = (" ".join(files))
|
||||||
|
with open(prifilepath, "w") as f:
|
||||||
|
f.write(pritemplate % {'files': tsfiles})
|
||||||
|
debug(git["add"](prifilepath))
|
||||||
|
|
||||||
|
# Write qrc file listing qm files built from ts files for build
|
||||||
|
qrcfilepath = os.path.join(wr_path, qrcfile)
|
||||||
|
info("Updating translations listing file '%s'", qrcfilepath)
|
||||||
|
tstoqm = lambda f: " <file>%s</file>" % re.sub(r"(^.*)\.ts$", r"\1.qm", f)
|
||||||
|
qmfiles = os.linesep.join([tstoqm(f) for f in files])
|
||||||
|
with open(qrcfilepath, "w") as f:
|
||||||
|
f.write(qrctemplate % {'files': qmfiles})
|
||||||
|
debug(git["add"](qrcfilepath))
|
||||||
|
|
||||||
|
# Check if the repo changed
|
||||||
debug("Checking for modifications")
|
debug("Checking for modifications")
|
||||||
changed, changedfiles, _ = git["diff", "--cached", "--name-only", "--exit-code"].run(retcode=(0,1))
|
changed, changedfiles, _ = git["diff", "--cached", "--name-only", "--exit-code"].run(retcode=(0,1))
|
||||||
if not changed:
|
if not changed:
|
||||||
|
|
Loading…
Reference in a new issue