Skip to content

Commit

Permalink
automations/translations (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl authored May 15, 2024
1 parent 2091a9f commit d19bfc3
Show file tree
Hide file tree
Showing 15 changed files with 404 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish_alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
- 'MANIFEST.in'
- 'readme.md'
- 'scripts/**'
- 'translations/**'
workflow_dispatch:

jobs:
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/sync_tx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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
if: github.event_name == 'push' && github.event.pull_request.merged && github.event.pull_request.head.user.login == 'gitlocalize-app'
run: |
python scripts/sync_translations.py
- name: Commit to dev
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update translations
branch: dev
53 changes: 53 additions & 0 deletions scripts/prepare_translations.py
Original file line number Diff line number Diff line change
@@ -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__))}/ovos_core/intent_services/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)
54 changes: 54 additions & 0 deletions scripts/sync_translations.py
Original file line number Diff line number Diff line change
@@ -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__))}/ovos_core/intent_services/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)))

24 changes: 24 additions & 0 deletions translations/de-de/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"stop.intent": [
"stop",
"stopp",
"genug (davon|)",
"schluss",
"schlu\u00df",
"schlie\u00dfen",
"ende",
"beenden",
"aufh\u00f6ren",
"h\u00f6r auf (damit|)",
"abbrechen",
"(brech|breche) ab",
"abbruch"
],
"global_stop.intent": [
"alles (stoppen|schlie\u00dfen|schliessen|beenden|abbrechen)",
"(schlie\u00dfe|schlie\u00df|schliess|stop|stoppe|beende) alles",
"(schlie\u00dfe|schlie\u00df|schliess|stop|stoppe|beende) alle (programme|anwendungen|prozesse|fenster|skills)",
"(breche|brech) alles ab",
"(breche|brech) (alle|) (programme|anwendungen|prozesse|fenster|skills) ab"
]
}
14 changes: 14 additions & 0 deletions translations/en-us/dialogs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"cant.play.dialog": [
"I'm not sure how to play {phrase}",
"Sorry, I don't know how to play {phrase}"
],
"play.what.dialog": [
"What should i play next?"
],
"just.one.moment.dialog": [
"Give me a moment",
"Just a second",
"Just one moment while I look for that"
]
}
115 changes: 115 additions & 0 deletions translations/en-us/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"play.intent": [
"(play|start) {query}",
"search (common play|ocp|ovos common play|O C P) for {query}",
"search (ovos|open voice os) media for {query}",
"search {query} (in|on) (common play|ocp|ovos common play|O C P)",
"search {query} (in|on) (ovos|open voice os) media"
],
"like_song.intent": [
"i like (that|this|it)",
"i like (that|this)(song|music|track|jam|sound)",
"(good|nice|great|amazing|awesome|cool) (song|music|track|jam|sound)",
"(that|this|it) is a (good|nice|great|amazing|awesome|cool) (song|music|track|jam|sound)"
],
"stop.intent": [
"stop",
"stop doing that",
"stop that",
"Stop what you're doing",
"Please stop that",
"Can you stop now",
"Stop performing that task",
"Please halt the current action",
"Stop the ongoing process",
"Cease the current activity",
"Please put an end to it",
"Stop working on that",
"Stop executing the current command",
"Please terminate the current task",
"Stop the current operation",
"Cease the current action",
"Please cancel the current task"
],
"next.intent": [
"(next|skip)",
"(next|skip) (music|song|track|video|media)",
"(play|go to) next (music|song|track|video|media)",
"play next",
"next",
"next (song|track|music|movie|video|tune)"
],
"resume.intent": [
"(unpause|resume)",
"(unpause|resume|continue|restart) (music|song|track|video|media|playback)",
"play"
],
"read.intent": [
"read (book|audiobook|audio book) {query}",
"read {query}",
"read {query} (book|audiobook|audio book)"
],
"prev.intent": [
"(play previous|go back one) (music|song|track|video|media)",
"(play previous|previous) (music|song|track|video|media)",
"(play previous|previous|go back)",
"previous",
"previous (song|track|music|movie|video|tune)"
],
"global_stop.intent": [
"stop all",
"end all",
"terminate all",
"cancel all",
"finish all",
"halt all",
"abort all",
"cease all",
"stop everything",
"end everything",
"terminate everything",
"cancel everything",
"finish everything",
"halt everything",
"abort everything",
"cease everything",
"Stop everything now",
"End all processes",
"Terminate all operations",
"Cancel all tasks",
"Finish all activities",
"Halt all activities immediately",
"Abort all ongoing processes",
"Cease all actions",
"Stop all current tasks",
"Terminate all running activities",
"Cancel all pending operations",
"Finish all open tasks",
"Halt all ongoing processes",
"Abort all running actions",
"Cease all active activities"
],
"pause.intent": [
"pause",
"pause (music|song|track|video|media|playback)"
],
"open.intent": [
"open (OCP|O C P|common|ovos|open voice os) (player|media player)",
"open (OCP|O C P|ovos common play|common play|ovos media player|open voice os player) (home screen|home page|homescreen|homepage|menu)",
"open (OCP|O C P|ovos common play|open voice os common play|common play)",
"open (media|music|gui|video) (player|catalog|skills|menu|playback)"
],
"featured.intent": [
"(open|show|display) (featured|) {media} (catalog|collection|playlist)",
"(open|show|display) featured {media}"
],
"play_favorites.intent": [
"(play|start) my (favorite|liked) (tracks|song|songs|music|jam|jams)",
"(play|start) (favorite|liked) (tracks|song|songs|music|jam|jams)"
],
"media_stop.intent": [
"stop",
"stop (playback|media|media playback|music|movie|movies|noise)",
"stop everything"
]
}
26 changes: 26 additions & 0 deletions translations/en-us/vocabs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"video_only.voc": [
"do not cast to audio",
"don't cast to audio",
"no audio player",
"only video",
"video only"
],
"Play.voc": [
"search",
"read",
"play",
"start"
],
"audio_only.voc": [
"audio only",
"no video",
"only audio",
"only sound",
"sound only"
],
"Resume.voc": [
"resume",
"unpause"
]
}
7 changes: 7 additions & 0 deletions translations/es-es/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"stop.intent": [
"Para",
"para de hacer eso",
"detener"
]
}
11 changes: 11 additions & 0 deletions translations/fr-fr/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"stop.intent": [
"arr\u00eate \u00e7a",
"arr\u00eate toi",
"arr\u00eate",
"stop",
"tais toi",
"chut",
"arr\u00eate de parler"
]
}
9 changes: 9 additions & 0 deletions translations/it-it/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"stop.intent": [
"basta",
"smettila",
"fermati",
"stop",
"piantala"
]
}
9 changes: 9 additions & 0 deletions translations/nl-be/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"stop.intent": [
"stop",
"bol het af",
"stop ermee",
"stoppen",
"stop subiet"
]
}
8 changes: 8 additions & 0 deletions translations/nl-nl/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"stop.intent": [
"stop",
"stop daarmee",
"stop ermee",
"stoppen"
]
}
7 changes: 7 additions & 0 deletions translations/pt-pt/intents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"stop.intent": [
"Pare com isso",
"Pare",
"Pare de fazer isso"
]
}
Loading

0 comments on commit d19bfc3

Please sign in to comment.