From 903c886d1e6d5d67e1a4143acd7c24b2c8c5596c Mon Sep 17 00:00:00 2001 From: miro Date: Sun, 17 Nov 2024 13:57:19 +0000 Subject: [PATCH] backup locale from old homescreen skill --- .github/workflows/sync_tx.yml | 37 ++++++++++++++ locale/ca-es/take.screenshot.intent | 2 + locale/da-dk/take.screenshot.intent | 1 + locale/de-de/take.screenshot.intent | 2 + locale/en-us/take.screenshot.intent | 2 + locale/es-es/take.screenshot.intent | 2 + locale/fr-fr/take.screenshot.intent | 2 + locale/it-it/take.screenshot.intent | 2 + locale/nl-nl/take.screenshot.intent | 2 + locale/pt-pt/take.screenshot.intent | 2 + scripts/sync_translations.py | 78 +++++++++++++++++++++++++++++ translations/ca-es/intents.json | 6 +++ translations/da-dk/intents.json | 6 +++ translations/de-de/intents.json | 6 +++ translations/en-us/intents.json | 6 +++ translations/es-es/intents.json | 6 +++ translations/fr-fr/intents.json | 6 +++ translations/it-it/intents.json | 6 +++ translations/nl-nl/intents.json | 6 +++ translations/pt-pt/intents.json | 6 +++ 20 files changed, 186 insertions(+) create mode 100644 .github/workflows/sync_tx.yml create mode 100644 locale/ca-es/take.screenshot.intent create mode 100644 locale/da-dk/take.screenshot.intent create mode 100644 locale/de-de/take.screenshot.intent create mode 100644 locale/en-us/take.screenshot.intent create mode 100644 locale/es-es/take.screenshot.intent create mode 100644 locale/fr-fr/take.screenshot.intent create mode 100644 locale/it-it/take.screenshot.intent create mode 100644 locale/nl-nl/take.screenshot.intent create mode 100644 locale/pt-pt/take.screenshot.intent create mode 100644 scripts/sync_translations.py create mode 100644 translations/ca-es/intents.json create mode 100644 translations/da-dk/intents.json create mode 100644 translations/de-de/intents.json create mode 100644 translations/en-us/intents.json create mode 100644 translations/es-es/intents.json create mode 100644 translations/fr-fr/intents.json create mode 100644 translations/it-it/intents.json create mode 100644 translations/nl-nl/intents.json create mode 100644 translations/pt-pt/intents.json diff --git a/.github/workflows/sync_tx.yml b/.github/workflows/sync_tx.yml new file mode 100644 index 0000000..5e7d307 --- /dev/null +++ b/.github/workflows/sync_tx.yml @@ -0,0 +1,37 @@ +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 manual dispatch + if: github.event_name == 'workflow_dispatch' + run: | + python scripts/sync_translations.py + + - 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/locale/ca-es/take.screenshot.intent b/locale/ca-es/take.screenshot.intent new file mode 100644 index 0000000..084fe3e --- /dev/null +++ b/locale/ca-es/take.screenshot.intent @@ -0,0 +1,2 @@ +fes una captura +fes una captura de pantalla \ No newline at end of file diff --git a/locale/da-dk/take.screenshot.intent b/locale/da-dk/take.screenshot.intent new file mode 100644 index 0000000..7ef7ae1 --- /dev/null +++ b/locale/da-dk/take.screenshot.intent @@ -0,0 +1 @@ +tag et skærmbillede \ No newline at end of file diff --git a/locale/de-de/take.screenshot.intent b/locale/de-de/take.screenshot.intent new file mode 100644 index 0000000..09693b1 --- /dev/null +++ b/locale/de-de/take.screenshot.intent @@ -0,0 +1,2 @@ +einen Screenshot machen +schauspielerisch \ No newline at end of file diff --git a/locale/en-us/take.screenshot.intent b/locale/en-us/take.screenshot.intent new file mode 100644 index 0000000..9e12b15 --- /dev/null +++ b/locale/en-us/take.screenshot.intent @@ -0,0 +1,2 @@ +take a screenshot +take screenshot \ No newline at end of file diff --git a/locale/es-es/take.screenshot.intent b/locale/es-es/take.screenshot.intent new file mode 100644 index 0000000..0dee90e --- /dev/null +++ b/locale/es-es/take.screenshot.intent @@ -0,0 +1,2 @@ +tomar captura de pantalla +tomar una captura de pantalla \ No newline at end of file diff --git a/locale/fr-fr/take.screenshot.intent b/locale/fr-fr/take.screenshot.intent new file mode 100644 index 0000000..3a8855e --- /dev/null +++ b/locale/fr-fr/take.screenshot.intent @@ -0,0 +1,2 @@ +capture d'écran +prendre une capture d'écran \ No newline at end of file diff --git a/locale/it-it/take.screenshot.intent b/locale/it-it/take.screenshot.intent new file mode 100644 index 0000000..5d253b4 --- /dev/null +++ b/locale/it-it/take.screenshot.intent @@ -0,0 +1,2 @@ +(scatta|fai) uno screenshot +scatta una foto(grafia|) \ No newline at end of file diff --git a/locale/nl-nl/take.screenshot.intent b/locale/nl-nl/take.screenshot.intent new file mode 100644 index 0000000..d0b3eeb --- /dev/null +++ b/locale/nl-nl/take.screenshot.intent @@ -0,0 +1,2 @@ +maak (een) schermafbeelding +schermenhot \ No newline at end of file diff --git a/locale/pt-pt/take.screenshot.intent b/locale/pt-pt/take.screenshot.intent new file mode 100644 index 0000000..3079283 --- /dev/null +++ b/locale/pt-pt/take.screenshot.intent @@ -0,0 +1,2 @@ +tirar a captura de tela +tirar uma captura de tela \ No newline at end of file diff --git a/scripts/sync_translations.py b/scripts/sync_translations.py new file mode 100644 index 0000000..342b469 --- /dev/null +++ b/scripts/sync_translations.py @@ -0,0 +1,78 @@ +"""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 = list(set([s.strip() for s in samples + if s and s.strip() != "[UNUSED]"])) # s may be None + if fid.startswith("/"): + p = f"{locale}/{lang.lower()}{fid}" + else: + p = f"{locale}/{lang.lower()}/{fid}" + os.makedirs(os.path.dirname(p), exist_ok=True) + with open(f"{locale}/{lang.lower()}/{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 = list(set([s.strip() for s in samples + if s and s.strip() != "[UNUSED]"])) # s may be None + if fid.startswith("/"): + p = f"{locale}/{lang.lower()}{fid}" + else: + p = f"{locale}/{lang.lower()}/{fid}" + os.makedirs(os.path.dirname(p), exist_ok=True) + with open(f"{locale}/{lang.lower()}/{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 = list(set([s.strip() for s in samples + if s and s.strip() != "[UNUSED]"])) # s may be None + if fid.startswith("/"): + p = f"{locale}/{lang.lower()}{fid}" + else: + p = f"{locale}/{lang.lower()}/{fid}" + os.makedirs(os.path.dirname(p), exist_ok=True) + with open(f"{locale}/{lang.lower()}/{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 = list(set([s.strip() for s in samples + if s and s.strip() != "[UNUSED]"])) # s may be None + if fid.startswith("/"): + p = f"{locale}/{lang.lower()}{fid}" + else: + p = f"{locale}/{lang.lower()}/{fid}" + os.makedirs(os.path.dirname(p), exist_ok=True) + with open(f"{locale}/{lang.lower()}/{fid}", "w") as f: + f.write("\n".join(sorted(samples))) + diff --git a/translations/ca-es/intents.json b/translations/ca-es/intents.json new file mode 100644 index 0000000..22f38fa --- /dev/null +++ b/translations/ca-es/intents.json @@ -0,0 +1,6 @@ +{ + "take.screenshot.intent": [ + "fes una captura de pantalla", + "fes una captura" + ] +} diff --git a/translations/da-dk/intents.json b/translations/da-dk/intents.json new file mode 100644 index 0000000..f2983ea --- /dev/null +++ b/translations/da-dk/intents.json @@ -0,0 +1,6 @@ +{ + "take.screenshot.intent": [ + "tag et skærmbillede", + "tag et skærmbillede" + ] +} diff --git a/translations/de-de/intents.json b/translations/de-de/intents.json new file mode 100644 index 0000000..bd10c63 --- /dev/null +++ b/translations/de-de/intents.json @@ -0,0 +1,6 @@ +{ + "take.screenshot.intent": [ + "einen Screenshot machen", + "schauspielerisch" + ] +} \ 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..a2123c3 --- /dev/null +++ b/translations/en-us/intents.json @@ -0,0 +1,6 @@ +{ + "take.screenshot.intent": [ + "take screenshot", + "take a screenshot" + ] +} \ 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..ab451ef --- /dev/null +++ b/translations/es-es/intents.json @@ -0,0 +1,6 @@ +{ + "take.screenshot.intent": [ + "tomar una captura de pantalla", + "tomar captura de pantalla" + ] +} \ 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..07763db --- /dev/null +++ b/translations/fr-fr/intents.json @@ -0,0 +1,6 @@ +{ + "take.screenshot.intent": [ + "prendre une capture d'\u00e9cran", + "capture d'\u00e9cran" + ] +} \ 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..6715e18 --- /dev/null +++ b/translations/it-it/intents.json @@ -0,0 +1,6 @@ +{ + "take.screenshot.intent": [ + "(scatta|fai) uno screenshot", + "scatta una foto(grafia|)" + ] +} diff --git a/translations/nl-nl/intents.json b/translations/nl-nl/intents.json new file mode 100644 index 0000000..db17bc5 --- /dev/null +++ b/translations/nl-nl/intents.json @@ -0,0 +1,6 @@ +{ + "take.screenshot.intent": [ + "maak (een) schermafbeelding", + "schermenhot" + ] +} diff --git a/translations/pt-pt/intents.json b/translations/pt-pt/intents.json new file mode 100644 index 0000000..7d31cd0 --- /dev/null +++ b/translations/pt-pt/intents.json @@ -0,0 +1,6 @@ +{ + "take.screenshot.intent": [ + "tirar uma captura de tela", + "tirar a captura de tela" + ] +} \ No newline at end of file