From ac194d0b1519c93178cc6150e4b2b58ca4bc3571 Mon Sep 17 00:00:00 2001 From: miro Date: Wed, 15 May 2024 04:50:20 +0100 Subject: [PATCH] automations/translations --- .github/workflows/publish_alpha.yml | 72 +++++++++++++++++++++++++++++ .github/workflows/sync_tx.yml | 32 +++++++++++++ scripts/prepare_translations.py | 53 +++++++++++++++++++++ scripts/sync_translations.py | 54 ++++++++++++++++++++++ translations/de-de/dialogs.json | 5 ++ translations/de-de/intents.json | 13 ++++++ translations/de-de/vocabs.json | 8 ++++ translations/en-us/dialogs.json | 5 ++ translations/en-us/intents.json | 13 ++++++ translations/en-us/vocabs.json | 8 ++++ translations/es-es/dialogs.json | 5 ++ translations/es-es/intents.json | 13 ++++++ translations/es-es/vocabs.json | 8 ++++ translations/fr-fr/dialogs.json | 5 ++ translations/fr-fr/intents.json | 12 +++++ translations/fr-fr/vocabs.json | 7 +++ translations/it-it/dialogs.json | 5 ++ translations/it-it/intents.json | 13 ++++++ translations/it-it/vocabs.json | 8 ++++ translations/pt-pt/dialogs.json | 5 ++ translations/pt-pt/intents.json | 5 ++ translations/pt-pt/vocabs.json | 3 ++ {qt5 => ui/qt5}/wolf.qml | 0 23 files changed, 352 insertions(+) create mode 100644 .github/workflows/publish_alpha.yml create mode 100644 .github/workflows/sync_tx.yml create mode 100644 scripts/prepare_translations.py create mode 100644 scripts/sync_translations.py create mode 100644 translations/de-de/dialogs.json create mode 100644 translations/de-de/intents.json create mode 100644 translations/de-de/vocabs.json create mode 100644 translations/en-us/dialogs.json create mode 100644 translations/en-us/intents.json create mode 100644 translations/en-us/vocabs.json create mode 100644 translations/es-es/dialogs.json create mode 100644 translations/es-es/intents.json create mode 100644 translations/es-es/vocabs.json create mode 100644 translations/fr-fr/dialogs.json create mode 100644 translations/fr-fr/intents.json create mode 100644 translations/fr-fr/vocabs.json create mode 100644 translations/it-it/dialogs.json create mode 100644 translations/it-it/intents.json create mode 100644 translations/it-it/vocabs.json create mode 100644 translations/pt-pt/dialogs.json create mode 100644 translations/pt-pt/intents.json create mode 100644 translations/pt-pt/vocabs.json rename {qt5 => ui/qt5}/wolf.qml (100%) diff --git a/.github/workflows/publish_alpha.yml b/.github/workflows/publish_alpha.yml new file mode 100644 index 0000000..b43f906 --- /dev/null +++ b/.github/workflows/publish_alpha.yml @@ -0,0 +1,72 @@ +# This workflow will generate a distribution and upload it to PyPI + +name: Publish Alpha Build ...aX +on: + push: + branches: + - dev + paths-ignore: + - 'test/**' + - 'examples/**' + - '.github/**' + - '.gitignore' + - 'LICENSE' + - 'CHANGELOG.md' + - 'MANIFEST.in' + - 'readme.md' + - 'scripts/**' + - 'translations/**' + workflow_dispatch: + +jobs: + build_and_publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: dev + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install Build Tools + run: | + python -m pip install build wheel + - name: Increment Version + run: | + VER=$(python setup.py --version) + python scripts/bump_alpha.py + - name: "Generate release changelog" + uses: heinrichreimer/github-changelog-generator-action@v2.3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + id: changelog + - name: Commit to dev + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Prepare alpha version package + branch: dev + - name: version + run: echo "::set-output name=version::$(python setup.py --version)" + id: version + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: V${{ steps.version.outputs.version }} + release_name: Release ${{ steps.version.outputs.version }} + body: | + Changes in this Release + ${{ steps.changelog.outputs.changelog }} + draft: false + prerelease: true + - name: Build Distribution Packages + run: | + python setup.py bdist_wheel + - name: Publish to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{secrets.PYPI_TOKEN}} diff --git a/.github/workflows/sync_tx.yml b/.github/workflows/sync_tx.yml new file mode 100644 index 0000000..2fd378e --- /dev/null +++ b/.github/workflows/sync_tx.yml @@ -0,0 +1,32 @@ +name: Run script on merge to dev by gitlocalize-app + +on: + workflow_dispatch: + push: + branches: + - dev + +jobs: + run-script: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v2 + with: + ref: dev + fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository. + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + - name: Run script if merged by gitlocalize-app[bot] + if: github.event_name == 'push' && github.event.head_commit.author.username == 'gitlocalize-app[bot]' + run: | + python scripts/sync_translations.py + + - name: Commit to dev + uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Update translations + branch: dev diff --git a/scripts/prepare_translations.py b/scripts/prepare_translations.py new file mode 100644 index 0000000..46dee45 --- /dev/null +++ b/scripts/prepare_translations.py @@ -0,0 +1,53 @@ +"""this script should run every time the contents of the locale folder change +except if PR originated from @gitlocalize-app +TODO - on commit to dev +""" + +import json +from os.path import dirname +import os + +locale = f"{dirname(dirname(__file__))}/locale" +tx = f"{dirname(dirname(__file__))}/translations" + + +for lang in os.listdir(locale): + intents = {} + dialogs = {} + vocs = {} + regexes = {} + for root, _, files in os.walk(f"{locale}/{lang}"): + b = root.split(f"/{lang}")[-1] + + for f in files: + if b: + fid = f"{b}/{f}" + else: + fid = f + with open(f"{root}/{f}") as fi: + strings = [l.replace("{{", "{").replace("}}", "}") + for l in fi.read().split("\n") if l.strip() + and not l.startswith("#")] + + if fid.endswith(".intent"): + intents[fid] = strings + elif fid.endswith(".dialog"): + dialogs[fid] = strings + elif fid.endswith(".voc"): + vocs[fid] = strings + elif fid.endswith(".rx"): + regexes[fid] = strings + + os.makedirs(f"{tx}/{lang}", exist_ok=True) + if intents: + with open(f"{tx}/{lang}/intents.json", "w") as f: + json.dump(intents, f, indent=4) + if dialogs: + with open(f"{tx}/{lang}/dialogs.json", "w") as f: + json.dump(dialogs, f, indent=4) + if vocs: + with open(f"{tx}/{lang}/vocabs.json", "w") as f: + json.dump(vocs, f, indent=4) + if regexes: + with open(f"{tx}/{lang}/regexes.json", "w") as f: + json.dump(regexes, f, indent=4) diff --git a/scripts/sync_translations.py b/scripts/sync_translations.py new file mode 100644 index 0000000..9322d94 --- /dev/null +++ b/scripts/sync_translations.py @@ -0,0 +1,54 @@ +"""this script should run in every PR originated from @gitlocalize-app +TODO - before PR merge +""" + +import json +from os.path import dirname +import os + +locale = f"{dirname(dirname(__file__))}/locale" +tx = f"{dirname(dirname(__file__))}/translations" + + +for lang in os.listdir(tx): + intents = f"{tx}/{lang}/intents.json" + dialogs = f"{tx}/{lang}/dialogs.json" + vocs = f"{tx}/{lang}/vocabs.json" + regexes = f"{tx}/{lang}/regexes.json" + + if os.path.isfile(intents): + with open(intents) as f: + data = json.load(f) + for fid, samples in data.items(): + if samples: + samples = [s for s in samples if s] # s may be None + with open(f"{locale}/{lang}/{fid}", "w") as f: + f.write("\n".join(sorted(samples))) + + if os.path.isfile(dialogs): + with open(dialogs) as f: + data = json.load(f) + for fid, samples in data.items(): + if samples: + samples = [s for s in samples if s] # s may be None + with open(f"{locale}/{lang}/{fid}", "w") as f: + f.write("\n".join(sorted(samples))) + + if os.path.isfile(vocs): + with open(vocs) as f: + data = json.load(f) + for fid, samples in data.items(): + if samples: + samples = [s for s in samples if s] # s may be None + with open(f"{locale}/{lang}/{fid}", "w") as f: + f.write("\n".join(sorted(samples))) + + if os.path.isfile(regexes): + with open(regexes) as f: + data = json.load(f) + for fid, samples in data.items(): + if samples: + samples = [s for s in samples if s] # s may be None + with open(f"{locale}/{lang}/{fid}", "w") as f: + f.write("\n".join(sorted(samples))) + diff --git a/translations/de-de/dialogs.json b/translations/de-de/dialogs.json new file mode 100644 index 0000000..597cb32 --- /dev/null +++ b/translations/de-de/dialogs.json @@ -0,0 +1,5 @@ +{ + "no_answer.dialog": [ + "der Wolf nicht wei\u00df, die Antwort" + ] +} \ No newline at end of file diff --git a/translations/de-de/intents.json b/translations/de-de/intents.json new file mode 100644 index 0000000..d170cf9 --- /dev/null +++ b/translations/de-de/intents.json @@ -0,0 +1,13 @@ +{ + "search_wolfie.intent": [ + "fragen Sie den Wolf \u00fcber {query}", + "Suche den Wolf nach {query}", + "was sagt Wolfram \u00fcber {query}", + "was sagt der Wolf \u00fcber {query}", + "Suche Wolf f\u00fcr {query}", + "was sagt Wolf alpha \u00fcber {query}", + "Suche wolfram alpha nach {query}", + "fragen Sie den Wolf {query}", + "Fragen Sie den Wolf alpha \u00fcber {query}" + ] +} \ No newline at end of file diff --git a/translations/de-de/vocabs.json b/translations/de-de/vocabs.json new file mode 100644 index 0000000..a52af55 --- /dev/null +++ b/translations/de-de/vocabs.json @@ -0,0 +1,8 @@ +{ + "More.voc": [ + "mehr", + "Ich habe mehr", + "Mehr erfahren", + "weiter" + ] +} \ No newline at end of file diff --git a/translations/en-us/dialogs.json b/translations/en-us/dialogs.json new file mode 100644 index 0000000..3934446 --- /dev/null +++ b/translations/en-us/dialogs.json @@ -0,0 +1,5 @@ +{ + "no_answer.dialog": [ + "the wolf does not know the answer" + ] +} \ No newline at end of file diff --git a/translations/en-us/intents.json b/translations/en-us/intents.json new file mode 100644 index 0000000..4851987 --- /dev/null +++ b/translations/en-us/intents.json @@ -0,0 +1,13 @@ +{ + "search_wolfie.intent": [ + "search wolfram alpha for {query}", + "search wolfram for {query}", + "ask the wolfram about {query}", + "ask the wolfram alpha about {query}", + "what does wolfram alpha say about {query}", + "what does wolfram say about {query}", + "ask the wolf {query}", + "search the wolf for {query}", + "what does the wolf say about {query}" + ] +} \ No newline at end of file diff --git a/translations/en-us/vocabs.json b/translations/en-us/vocabs.json new file mode 100644 index 0000000..6d5edde --- /dev/null +++ b/translations/en-us/vocabs.json @@ -0,0 +1,8 @@ +{ + "More.voc": [ + "know more", + "tell me more", + "tell more", + "continue" + ] +} \ No newline at end of file diff --git a/translations/es-es/dialogs.json b/translations/es-es/dialogs.json new file mode 100644 index 0000000..644e291 --- /dev/null +++ b/translations/es-es/dialogs.json @@ -0,0 +1,5 @@ +{ + "no_answer.dialog": [ + "el lobo no sabe la respuesta" + ] +} \ No newline at end of file diff --git a/translations/es-es/intents.json b/translations/es-es/intents.json new file mode 100644 index 0000000..591998e --- /dev/null +++ b/translations/es-es/intents.json @@ -0,0 +1,13 @@ +{ + "search_wolfie.intent": [ + "\u00bfQu\u00e9 dice el lobo acerca de {query}", + "Preg\u00fantale al lobo", + "buscar el lobo para {query}", + "\u00bfQu\u00e9 dice Wolfram Alpha sobre {query}", + "buscar wolfram para {query}", + "\u00bfQu\u00e9 dice wolfram acerca de {query}", + "Preg\u00fantale al loboram alpha sobre {query}", + "Preg\u00fantale al wolfram sobre {query}", + "buscar wolfram alpha para {query}" + ] +} \ No newline at end of file diff --git a/translations/es-es/vocabs.json b/translations/es-es/vocabs.json new file mode 100644 index 0000000..30eec60 --- /dev/null +++ b/translations/es-es/vocabs.json @@ -0,0 +1,8 @@ +{ + "More.voc": [ + "Dime m\u00e1s", + "saber m\u00e1s", + "Diga m\u00e1s", + "continuar" + ] +} \ No newline at end of file diff --git a/translations/fr-fr/dialogs.json b/translations/fr-fr/dialogs.json new file mode 100644 index 0000000..2edc332 --- /dev/null +++ b/translations/fr-fr/dialogs.json @@ -0,0 +1,5 @@ +{ + "no_answer.dialog": [ + "le loup ne conna\u00eet pas la r\u00e9ponse" + ] +} \ No newline at end of file diff --git a/translations/fr-fr/intents.json b/translations/fr-fr/intents.json new file mode 100644 index 0000000..8a8ff87 --- /dev/null +++ b/translations/fr-fr/intents.json @@ -0,0 +1,12 @@ +{ + "search_wolfie.intent": [ + "chercher wolfram alpha pour {query}", + "Que dit le loup sur la laque", + "posez-vous la question au loup", + "chercher le loup pour {query}", + "ce que dit le loup-garou sur", + "que dit le wolfram alpha sur {query}", + "posez-vous au loup-garou alpha sur {query}", + "Demande au loup" + ] +} \ No newline at end of file diff --git a/translations/fr-fr/vocabs.json b/translations/fr-fr/vocabs.json new file mode 100644 index 0000000..419a892 --- /dev/null +++ b/translations/fr-fr/vocabs.json @@ -0,0 +1,7 @@ +{ + "More.voc": [ + "continue", + "Dis-moi plus", + "En savoir plus" + ] +} \ No newline at end of file diff --git a/translations/it-it/dialogs.json b/translations/it-it/dialogs.json new file mode 100644 index 0000000..07194a3 --- /dev/null +++ b/translations/it-it/dialogs.json @@ -0,0 +1,5 @@ +{ + "no_answer.dialog": [ + "il lupo non conosce la risposta" + ] +} \ No newline at end of file diff --git a/translations/it-it/intents.json b/translations/it-it/intents.json new file mode 100644 index 0000000..9dc43b7 --- /dev/null +++ b/translations/it-it/intents.json @@ -0,0 +1,13 @@ +{ + "search_wolfie.intent": [ + "cerca il lupo per {query}", + "ricerca wolfram per {query}", + "che cosa dice wolfram alpha su {query}", + "che cosa dice wolfram su {query}", + "che cosa dice il lupo su {query}", + "chiedere al lupo {query}", + "chiedere al lupo alfa di {query}", + "chiedere al lupo di {query}", + "ricerca wolfram alpha per {query}" + ] +} \ No newline at end of file diff --git a/translations/it-it/vocabs.json b/translations/it-it/vocabs.json new file mode 100644 index 0000000..5d633ab --- /dev/null +++ b/translations/it-it/vocabs.json @@ -0,0 +1,8 @@ +{ + "More.voc": [ + "continuare", + "Dimmi di pi\u00f9", + "Di pi\u00f9", + "sapere di pi\u00f9" + ] +} \ No newline at end of file diff --git a/translations/pt-pt/dialogs.json b/translations/pt-pt/dialogs.json new file mode 100644 index 0000000..3064025 --- /dev/null +++ b/translations/pt-pt/dialogs.json @@ -0,0 +1,5 @@ +{ + "no_answer.dialog": [ + "o lobo n\u00e3o sabe a resposta" + ] +} \ No newline at end of file diff --git a/translations/pt-pt/intents.json b/translations/pt-pt/intents.json new file mode 100644 index 0000000..7fbd16b --- /dev/null +++ b/translations/pt-pt/intents.json @@ -0,0 +1,5 @@ +{ + "search_wolfie.intent": [ + "pergunta ao lobo {query}" + ] +} \ No newline at end of file diff --git a/translations/pt-pt/vocabs.json b/translations/pt-pt/vocabs.json new file mode 100644 index 0000000..4c74d1b --- /dev/null +++ b/translations/pt-pt/vocabs.json @@ -0,0 +1,3 @@ +{ + "More.voc": [] +} \ No newline at end of file diff --git a/qt5/wolf.qml b/ui/qt5/wolf.qml similarity index 100% rename from qt5/wolf.qml rename to ui/qt5/wolf.qml