diff --git a/build/jenkins/dockerfiles/translations.Dockerfile b/build/jenkins/dockerfiles/translations.Dockerfile index 7b03b5502e..90fb85712c 100644 --- a/build/jenkins/dockerfiles/translations.Dockerfile +++ b/build/jenkins/dockerfiles/translations.Dockerfile @@ -13,6 +13,8 @@ RUN apt-get -qq update && apt-get install -qqy --no-install-recommends \ ENV SHELL /bin/bash RUN pip3 install setuptools wheel -RUN pip3 install transifex-client lxml babel +RUN pip3 install lxml babel +RUN curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash +RUN install tx /usr/bin/tx USER builder COPY --chown=builder transifexrc /home/builder/.transifexrc diff --git a/build/jenkins/pipelines/docker-translations.Jenkinsfile b/build/jenkins/pipelines/docker-translations.Jenkinsfile index 2d3edd0ccb..7ec83f61d0 100644 --- a/build/jenkins/pipelines/docker-translations.Jenkinsfile +++ b/build/jenkins/pipelines/docker-translations.Jenkinsfile @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2023 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -41,11 +41,15 @@ pipeline { steps { ws('/zpool0/translations') { withDockerContainer("0ad-translations:latest") { - sh "python3 --version" + sh "python3 source/tools/i18n/updateTemplates.py" + withCredentials([string(credentialsId: 'redacted', variable: 'token')]) { + sh 'TX_TOKEN="$token" python3 source/tools/i18n/pullTranslations.py' + } dir("source/tools/i18n/") { - sh "./maintenanceTasks.sh" sh "python3 generateDebugTranslation.py --long" } + sh "python3 source/tools/i18n/cleanTranslationFiles.py" + sh "python3 source/tools/i18n/checkDiff.py --verbose" } } } @@ -55,14 +59,13 @@ pipeline { steps { ws('/zpool0/translations') { withCredentials([usernamePassword(credentialsId: 'redacted', passwordVariable: 'SVNPASS', usernameVariable: 'SVNUSER')]) { - sh "svn relocate --username ${SVNUSER} --password ${SVNPASS} --no-auth-cache https://svn.wildfiregames.com/svn/ps/trunk" - sh "svn commit --username ${SVNUSER} --password ${SVNPASS} --no-auth-cache --non-interactive -m '[i18n] Updated POT and PO files.'" + sh 'svn relocate --username $SVNUSER --password $SVNPASS --no-auth-cache https://svn.wildfiregames.com/svn/ps/trunk' + sh 'svn commit --username $SVNUSER --password $SVNPASS --no-auth-cache --non-interactive -m "[i18n] Updated POT and PO files."' } } } } } - post { always { sleep 10 diff --git a/source/tools/i18n/cleanTranslationFiles.py b/source/tools/i18n/cleanTranslationFiles.py index 4425af9eec..fec86e10a8 100644 --- a/source/tools/i18n/cleanTranslationFiles.py +++ b/source/tools/i18n/cleanTranslationFiles.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2022 Wildfire Games. +# Copyright (C) 2023 Wildfire Games. # This file is part of 0 A.D. # # 0 A.D. is free software: you can redistribute it and/or modify @@ -32,7 +32,6 @@ from i18n_helper import l10nFolderName, transifexClientFolder, projectRootDirect def main(): # Prepare some regexes. - commentMatch = re.compile('#.*') translatorMatch = re.compile("(# [^,<]*)(?: <.*>)?(?:, [0-9,-]{4,9})") lastTranslatorMatch = re.compile("(\"Last-Translator: [^,<]*)(?: <.*>)?( ?\\\\n\")") @@ -45,7 +44,7 @@ def main(): for file in files: usernames = [] reached = False - for line in fileinput.input(file.replace("\\", "/"), inplace=1): + for line in fileinput.input(file.replace("\\", "/"), inplace=True, encoding="utf-8"): if reached: if line == "# \n": line = "" diff --git a/source/tools/i18n/pullTranslations.py b/source/tools/i18n/pullTranslations.py index 58335ceec7..49b36f8379 100644 --- a/source/tools/i18n/pullTranslations.py +++ b/source/tools/i18n/pullTranslations.py @@ -29,7 +29,7 @@ def main(): path = os.path.join(root, folder) os.chdir(path) print(f"INFO: Starting to pull translations in {path}...") - subprocess.run("tx pull -f") + subprocess.run(["tx", "pull", "-f"]) if __name__ == "__main__": diff --git a/source/tools/i18n/requirements.txt b/source/tools/i18n/requirements.txt index b02137b1fb..c5c7edb99a 100644 --- a/source/tools/i18n/requirements.txt +++ b/source/tools/i18n/requirements.txt @@ -1 +1,2 @@ +babel~=2.6 lxml~=4.5