mirror of
https://github.com/etlegacy/LegacyTransifexBot.git
synced 2024-11-21 11:51: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
|
||||
; %(langcount)d Number of languages matched with given settings
|
||||
commit = Transifex translation update
|
||||
|
||||
Mode: %(mode)s
|
||||
Minimum percent translated: %(minpercent)s
|
||||
Matched %(langcount)d languages
|
||||
|
||||
[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
|
||||
; if changes occur.
|
||||
file = src/mumble/translations.pri
|
||||
prifile = src/mumble/translations.pri
|
||||
; Template to generate file from, available variables $(files)s
|
||||
; for a space separated list of all files.
|
||||
template = # Do not change manually
|
||||
pritemplate = # Do not change manually
|
||||
# Autogenerated by mumble transifex bot
|
||||
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
|
||||
additionaltsfiles = mumble_en.ts
|
||||
additionaltsfiles = mumble_en.ts
|
|
@ -116,8 +116,10 @@ if __name__ == "__main__":
|
|||
pr_body = cfg.get('pullrequest', 'body')
|
||||
pr_commit = cfg.get('pullrequest', 'commit')
|
||||
|
||||
translationsfile = cfg.get('misc', 'file')
|
||||
translationstemplate = cfg.get('misc', 'template')
|
||||
prifile = cfg.get('misc', 'prifile')
|
||||
pritemplate = cfg.get('misc', 'pritemplate')
|
||||
qrcfile = cfg.get('misc', 'qrcfile')
|
||||
qrctemplate = cfg.get('misc', 'qrctemplate')
|
||||
additionaltsfiles = cfg.get('misc', 'additionaltsfiles')
|
||||
|
||||
if args.setup or not os.path.exists(wr_path):
|
||||
|
@ -161,28 +163,44 @@ if __name__ == "__main__":
|
|||
debug(git["reset", remote + "/" + branch, "--hard"]())
|
||||
info("Cleaning repository")
|
||||
debug(git["clean", "-f", "-x", "-d"]())
|
||||
info("Pulling translations")
|
||||
|
||||
info("Pulling translations")
|
||||
txout = tx["pull", "-f", "-a", "--mode=" + mode, "--minimum-perc=" + minpercent]()
|
||||
debug(txout)
|
||||
|
||||
tfilepath = os.path.join(wr_path, translationsfile)
|
||||
info("Updating translations listing file '%s'", tfilepath)
|
||||
# Add all .ts files tx pull got to repo
|
||||
paths, files = zip(*re.findall(r"^\s->\s[\w_]+:\s([\w/\_]+/([\w_]+\.ts))$", txout, flags=re.MULTILINE))
|
||||
debug(git["add"](*paths))
|
||||
translations = additionaltsfiles + " " + (" ".join(sorted(files)))
|
||||
|
||||
with open(tfilepath, "w") as f:
|
||||
f.write(translationstemplate % {'files': translations})
|
||||
|
||||
debug(git["add"](tfilepath))
|
||||
|
||||
# Add additional ts files not in control of transifex (e.g. English source translation)
|
||||
files = list(files)
|
||||
files.extend(additionaltsfiles.split(" "))
|
||||
files.sort()
|
||||
|
||||
# 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")
|
||||
changed, changedfiles, _ = git["diff", "--cached", "--name-only", "--exit-code"].run(retcode=(0,1))
|
||||
if not changed:
|
||||
info("No changes to translations, done")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
debug("Changed files: %s", " ".join(os.linesep.split(changedfiles)))
|
||||
|
||||
info("Things changed & force pushing")
|
||||
|
|
Loading…
Reference in a new issue