Skip to content

Commit

Permalink
Merge branch 'dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl authored May 16, 2024
2 parents 24778a8 + 4de136f commit 8dc11a6
Show file tree
Hide file tree
Showing 21 changed files with 726 additions and 55 deletions.
52 changes: 0 additions & 52 deletions .github/workflows/auto_translate.yml

This file was deleted.

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
32 changes: 32 additions & 0 deletions .github/workflows/sync_tx.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [Unreleased](https://github.com/OpenVoiceOS/skill-ovos-news/tree/HEAD)

[Full Changelog](https://github.com/OpenVoiceOS/skill-ovos-news/compare/V0.0.4a4...HEAD)

**Closed issues:**

- No module named 'mycroft\_bus\_client' [\#24](https://github.com/OpenVoiceOS/skill-ovos-news/issues/24)

## [V0.0.4a4](https://github.com/OpenVoiceOS/skill-ovos-news/tree/V0.0.4a4) (2024-01-13)

[Full Changelog](https://github.com/OpenVoiceOS/skill-ovos-news/compare/V0.0.4a3...V0.0.4a4)

## [V0.0.4a3](https://github.com/OpenVoiceOS/skill-ovos-news/tree/V0.0.4a3) (2024-01-12)

[Full Changelog](https://github.com/OpenVoiceOS/skill-ovos-news/compare/V0.0.4a2...V0.0.4a3)
Expand Down
2 changes: 1 addition & 1 deletion scripts/prepare_skillstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

base_dir = dirname(dirname(__file__))
desktop_dir = join(base_dir, "res", "desktop")
android_ui = join(base_dir, "res", "+android")
android_ui = join(base_dir, "qt5", "+android")
makedirs(desktop_dir, exist_ok=True)

readme = join(base_dir, "README.md")
Expand Down
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__))}/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)
58 changes: 58 additions & 0 deletions scripts/sync_translations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""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.strip() for s in samples
if s and s.strip() != "[UNUSED]"] # 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.strip() for s in samples
if s and s.strip() != "[UNUSED]"] # 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.strip() for s in samples
if s and s.strip() != "[UNUSED]"] # 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.strip() for s in samples
if s and s.strip() != "[UNUSED]"] # s may be None
with open(f"{locale}/{lang}/{fid}", "w") as f:
f.write("\n".join(sorted(samples)))

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_requirements(requirements_filename: str):


def find_resource_files():
resource_base_dirs = ("locale", "res", "vocab", "dialog", "regex", "skill")
resource_base_dirs = ("locale", "qt5", "vocab", "dialog", "regex", "skill")
base_dir = path.dirname(__file__)
package_data = ["*.json"]
for res in resource_base_dirs:
Expand Down
5 changes: 5 additions & 0 deletions translations/de-de/dialogs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"intro.dialog": [
"Danke f\u00fcr die Installation News Skill"
]
}
125 changes: 125 additions & 0 deletions translations/de-de/vocabs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"video.voc": [
"Video",
"mit video"
],
"rt.voc": [
"Russland heute"
],
"it.voc": [
"aus italien",
"italien",
"italienisch",
"italienische"
],
"en-ca.voc": [
"aus kanada",
"kanada",
"kanadisch",
"kanadische"
],
"nl.voc": [
"aus holland",
"aus niederlande",
"aus den niederlanden",
"holland",
"niederland",
"holl\u00e4ndisch",
"holl\u00e4ndische",
"niederl\u00e4ndisch",
"niederl\u00e4ndische"
],
"ca.voc": [
"aus katalonien",
"Katalonien",
"Katalanisch",
"katalonische"
],
"euronews.voc": [
"Euronews"
],
"fr.voc": [
"aus frankreich",
"frankreich",
"franz\u00f6sisch",
"franz\u00f6sische"
],
"es.voc": [
"aus spanien",
"spanien",
"Spanisch",
"spanische"
],
"news.voc": [
"die nachrichten",
"nachrichten"
],
"en-au.voc": [
"aus Australien",
"Australien",
"australisch",
"australische"
],
"pt-pt.voc": [
"aus portugal",
"portugal",
"portugiesisch",
"portugiesische"
],
"euro.voc": [
"aus europa",
"europa",
"europ\u00e4isch",
"Europ\u00e4ische",
"Euro"
],
"en.voc": [
"aus dem Vereinigten K\u00f6nigreich",
"aus England",
"england",
"englische"
],
"de.voc": [
"aus deutschland",
"deutschland",
"deutsch",
"deutsche"
],
"fr24.voc": [
"Frankreich 24",
"Frankreich zwanzig vier",
"Frankreich24",
"Frankreich zwanzig vierte"
],
"fi.voc": [
"aus finnland",
"finnland",
"finnisch",
"finnische"
],
"sv.voc": [
"aus schweden",
"schweden",
"schwedisch",
"schwedische"
],
"en-gb.voc": [
"aus dem Vereinigten K\u00f6nigreich",
"aus England",
"england",
"englische"
],
"ru.voc": [
"aus russland",
"russland",
"russisch",
"russische"
],
"en-us.voc": [
"aus den vereinigten Staaten",
"aus amerika",
"amerika",
"amerikanisch",
"amerikanische"
]
}
5 changes: 5 additions & 0 deletions translations/en-us/dialogs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"intro.dialog": [
"thank you for installing News Skill"
]
}
Loading

0 comments on commit 8dc11a6

Please sign in to comment.