Skip to content

Commit

Permalink
backup locale from old homescreen skill
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Nov 17, 2024
0 parents commit 903c886
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/sync_tx.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions locale/ca-es/take.screenshot.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fes una captura
fes una captura de pantalla
1 change: 1 addition & 0 deletions locale/da-dk/take.screenshot.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tag et skærmbillede
2 changes: 2 additions & 0 deletions locale/de-de/take.screenshot.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
einen Screenshot machen
schauspielerisch
2 changes: 2 additions & 0 deletions locale/en-us/take.screenshot.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
take a screenshot
take screenshot
2 changes: 2 additions & 0 deletions locale/es-es/take.screenshot.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tomar captura de pantalla
tomar una captura de pantalla
2 changes: 2 additions & 0 deletions locale/fr-fr/take.screenshot.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
capture d'écran
prendre une capture d'écran
2 changes: 2 additions & 0 deletions locale/it-it/take.screenshot.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(scatta|fai) uno screenshot
scatta una foto(grafia|)
2 changes: 2 additions & 0 deletions locale/nl-nl/take.screenshot.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
maak (een) schermafbeelding
schermenhot
2 changes: 2 additions & 0 deletions locale/pt-pt/take.screenshot.intent
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tirar a captura de tela
tirar uma captura de tela
78 changes: 78 additions & 0 deletions scripts/sync_translations.py
Original file line number Diff line number Diff line change
@@ -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)))

6 changes: 6 additions & 0 deletions translations/ca-es/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"take.screenshot.intent": [
"fes una captura de pantalla",
"fes una captura"
]
}
6 changes: 6 additions & 0 deletions translations/da-dk/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"take.screenshot.intent": [
"tag et skærmbillede",
"tag et skærmbillede"
]
}
6 changes: 6 additions & 0 deletions translations/de-de/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"take.screenshot.intent": [
"einen Screenshot machen",
"schauspielerisch"
]
}
6 changes: 6 additions & 0 deletions translations/en-us/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"take.screenshot.intent": [
"take screenshot",
"take a screenshot"
]
}
6 changes: 6 additions & 0 deletions translations/es-es/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"take.screenshot.intent": [
"tomar una captura de pantalla",
"tomar captura de pantalla"
]
}
6 changes: 6 additions & 0 deletions translations/fr-fr/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"take.screenshot.intent": [
"prendre une capture d'\u00e9cran",
"capture d'\u00e9cran"
]
}
6 changes: 6 additions & 0 deletions translations/it-it/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"take.screenshot.intent": [
"(scatta|fai) uno screenshot",
"scatta una foto(grafia|)"
]
}
6 changes: 6 additions & 0 deletions translations/nl-nl/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"take.screenshot.intent": [
"maak (een) schermafbeelding",
"schermenhot"
]
}
6 changes: 6 additions & 0 deletions translations/pt-pt/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"take.screenshot.intent": [
"tirar uma captura de tela",
"tirar a captura de tela"
]
}

0 comments on commit 903c886

Please sign in to comment.