Skip to content

Commit

Permalink
MAINT/CI: Add --ci-mode option to translation update script
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Krzmbrzl committed Mar 28, 2021
1 parent ff373bc commit 0343d2b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .ci/azure-pipelines/assertNoTranslationChanges.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ git config user.name "CI"
git config user.email "[email protected]"

# Execute updatetranslations that'll commit any translation changes
python $updateScript
python $updateScript --ci-mode
echo

# Ger new commit hash
Expand Down
18 changes: 13 additions & 5 deletions scripts/updatetranslations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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:
Expand All @@ -80,7 +87,8 @@ def Update(lupdatebin, tsfile: str, debuglupdate: bool) -> (int, int, int):
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()

Expand Down Expand Up @@ -111,7 +119,7 @@ def Update(lupdatebin, tsfile: str, debuglupdate: bool) -> (int, int, int):
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
Expand Down

0 comments on commit 0343d2b

Please sign in to comment.