diff options
author | Robert Adam <dev@robert-adam.de> | 2021-03-28 20:57:10 +0300 |
---|---|---|
committer | Robert Adam <dev@robert-adam.de> | 2021-03-28 20:58:54 +0300 |
commit | 0343d2b002fd85387487fb2625c42174a5a3b9a4 (patch) | |
tree | 971effa6421fa1247e30960d892be9e9ee267edb /scripts | |
parent | ff373bc27207a47d7ccec74fc3cc16f55bbdd54c (diff) |
MAINT/CI: Add --ci-mode option to translation update script
In this mode the sametext heuristic is disabled which _should_ fix the
issue of the Weblate PR's CI failing because of Weblate not applying
such heuristics.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/updatetranslations.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/scripts/updatetranslations.py b/scripts/updatetranslations.py index 696f18670..5f1f31fc8 100755 --- a/scripts/updatetranslations.py +++ b/scripts/updatetranslations.py @@ -49,8 +49,8 @@ def Commit(tsfiles: list) -> None: logging.debug('stdout: %s', res.stdout)
exit(1) -def Update(lupdatebin, tsfile: str, debuglupdate: bool) -> (int, int, int): - res = subprocess.run([ +def Update(lupdatebin, tsfile: str, debuglupdate: bool, applyHeuristics = True) -> (int, int, int): + runArray = [ lupdatebin , '-no-ui-lines' # {sametext|similartext|number} @@ -64,7 +64,14 @@ def Update(lupdatebin, tsfile: str, debuglupdate: bool) -> (int, int, int): , './src', './src/mumble' # target , '-ts', tsfile - ], capture_output=True) + ] + + if not applyHeuristics: + runArray.insert(2, '-disable-heuristic') + runArray.insert(3, 'sametext') + + res = subprocess.run(runArray, capture_output=True) + if debuglupdate: logging.debug(res.stdout) if res.returncode != 0: @@ -80,7 +87,8 @@ if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--vcpkg-triplet', type=str, required=False, help='the vcpkg triplet to use the lupdate tool from, e.g. "x64-windows-static-md"') parser.add_argument('--debug', dest='debug', action='store_true') - parser.add_argument('--debug-lupdate', dest='debuglupdate', action='store_true') + parser.add_argument('--debug-lupdate', dest='debuglupdate', action='store_true', default=False) + parser.add_argument('--ci-mode', action='store_true') parser.set_defaults(debug=False, debuglupdate=False) args = parser.parse_args() @@ -111,7 +119,7 @@ if __name__ == '__main__': mismatch = False for tsfile in tsfiles: logging.debug('Updating ts file ' + tsfile + '…') - (resnsrc, resnnew, resnsame) = Update(lupdatebin, tsfile, args.debuglupdate) + (resnsrc, resnnew, resnsame) = Update(lupdatebin, tsfile, args.debuglupdate, applyHeuristics = not args.ci_mode) if nsrc is None: nsrc = resnsrc nnew = resnnew |