OpenVoiceOS / ovos-installer

Open Voice OS and/or HiveMind installer using Ansible with an intuitive and easy Text-based User Interface
https://www.openvoiceos.org
79 stars 21 forks source link

feat:gitlocalize #161

Closed JarbasAl closed 1 month ago

JarbasAl commented 1 month ago

adds support for integrating with Gitlocalize

whenever a PR from gitlocalize bot is merged the sync_translations.py script will run and update the locale folder with user submitted strings from GitLocalize platform

also closes #160 (typo)

the script has been run to validate it didnt mess the files, please check the minor formatting changes caused by the script

Summary by CodeRabbit

coderabbitai[bot] commented 1 month ago

[!CAUTION]

Review failed

The pull request is closed.

Walkthrough

A new GitHub Actions workflow named sync_tx.yml has been added to automate the synchronization of translation files. This workflow triggers on pushes to the dev branch and can also be manually dispatched. Additionally, several JSON files containing translations in multiple languages (English and French) have been created for the Open Voice OS installation process, along with minor textual corrections and formatting adjustments in various localization scripts.

Changes

File Path Change Summary
.github/workflows/sync_tx.yml New workflow added to automate synchronization of translation files on push and manual dispatch.
translations/en-us/strings.json New English translations for installation scripts added.
translations/fr-fr/strings.json New French translations for installation scripts added.
tui/locales/en-us/summary.sh Minor formatting changes for summary output in English.
tui/locales/fr-fr/channels.sh Textual corrections in French localization.
tui/locales/fr-fr/features.sh Textual modifications for clarity in French localization.
tui/locales/fr-fr/finish.sh Punctuation adjustments in French text.
tui/locales/fr-fr/methods.sh Formatting changes for consistency in French text.
tui/locales/fr-fr/summary.sh Formatting adjustments for summary message in French.
tui/locales/fr-fr/telemetry.sh Minor textual modifications for clarity in French localization.
tui/locales/fr-fr/tuning.sh Minor formatting change in French text.
tui/locales/fr-fr/uninstall.sh Formatting adjustments in French prompts related to uninstallation.

Possibly related PRs

Poem

🐇 In the meadow where translations bloom,
New scripts and workflows dispel the gloom.
From English to French, each phrase takes flight,
Guiding users with words, clear and bright.
With every push, our voices unite,
Celebrating changes, oh what a delight! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
JarbasAl commented 1 month ago

for reference, this was the quick script to parse locale files

import json
import os
from os.path import dirname

FILES = ['misc.sh', 'channels.sh', 'detection.sh', 'features.sh',
         'finish.sh', 'methods.sh', 'profiles.sh', 'satellite.sh',
         'summary.sh', 'telemetry.sh', 'tuning.sh', 'uninstall.sh',
         'welcome.sh']

TRANSLATIONS_FOLDER = f"{dirname(dirname(__file__))}/translations"
LOCALE_FOLDER = f"{dirname(dirname(__file__))}/tui/locales"

def get_key(k, lines, f):
    in_k = False
    val = ""
    for l in lines:
        if l.strip().startswith("#"):
            continue  # comment
        if f == "satellite.sh" and k == "content" and 'content="' in l:
            in_k = True
        elif l.strip() == '"':
            in_k = False
        elif l.startswith("export "):
            in_k = False
        elif l.startswith(f"{k.upper()}="):
            in_k = True
        elif '="' in l:
            in_k = False
        if in_k:
            if f == "satellite.sh" and l.strip() == "$content":
                continue
            l = l.split('="')[-1]
            if l.endswith('"'):
                l = l[:-1]
            val += f"\n{l}"
    return val.strip()

def get_locale(lang):
    DATA = {}
    for f in FILES:
        try:
            with open(f"{LOCALE_FOLDER}/{lang}/{f}", "r") as fi:
                lines = fi.read().split("\n")
        except:
            print(f"missing file: {lang}/{f}")
            continue
        # print(lang, data)
        if f == "satellite.sh":
            DATA[f] = {
                "title_host": get_key("title_host", lines, f),
                "title_port": get_key("title_port", lines, f),
                "title_key": get_key("title_key", lines, f),
                "title_password": get_key("title_password", lines, f),
                "content": get_key("content", lines, f),
                "content_host": get_key("content_host", lines, f),
                "content_port": get_key("content_port", lines, f),
                "content_key": get_key("content_key", lines, f),
                "content_password": get_key("content_password", lines, f),
            }
        elif f == "features.sh":
            DATA[f] = {
                "title": get_key("title", lines, f),
                "content": get_key("content", lines, f),
                "skill_description": get_key("skill_description", lines, f),
                "extra_skill_description": get_key("extra_skill_description", lines, f),
                "gui_description": get_key("gui_description", lines, f)
            }
        elif f == "misc.sh":
            DATA[f] = {
                "ok_button": get_key("ok_button", lines, f),
                "yes_button": get_key("yes_button", lines, f),
                "no_button": get_key("no_button", lines, f),
                "back_button": get_key("back_button", lines, f),
            }
        else:
            DATA[f] = {
                "title": get_key("title", lines, f),
                "content": get_key("content", lines, f),
            }
    return DATA

for lang in os.listdir(LOCALE_FOLDER):
    data = get_locale(lang)
    print(lang, data)
    for f in FILES:
        os.makedirs(f"{TRANSLATIONS_FOLDER}/{lang}", exist_ok=True)
        with open(f"{TRANSLATIONS_FOLDER}/{lang}/strings.json", "w") as f:
            json.dump(data, f, indent=2, ensure_ascii=False)