Skip to content

Add Hebrew locale with RTL support and finalize translations#1711

Open
lidorshimoni wants to merge 10 commits intohacksider:mainfrom
lidorshimoni:main
Open

Add Hebrew locale with RTL support and finalize translations#1711
lidorshimoni wants to merge 10 commits intohacksider:mainfrom
lidorshimoni:main

Conversation

@lidorshimoni
Copy link
Copy Markdown

@lidorshimoni lidorshimoni commented Mar 28, 2026

UI verification screenshots

Hebrew (localized + RTL) — proof of fix

014946b7-92d7-4f86-ad5b-2e42110fbd13 b89ca9ce-8d39-4fc6-a12b-a547c7b17fb9

Summary by Sourcery

Add RTL-aware localization support for Hebrew and apply translations to additional UI labels.

New Features:

  • Introduce RTL language handling that prefixes translated strings with an RTL mark for supported locales.
  • Add a Hebrew locale file providing Hebrew translations for UI text.

Enhancements:

  • Use localized strings for several previously hard-coded UI labels such as face enhancer, transparency, sharpness, and mouth mask.

Copilot AI review requested due to automatic review settings March 28, 2026 11:29
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Mar 28, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds RTL-aware translation handling, wires several remaining UI labels into the i18n system, and introduces a Hebrew locale JSON file for full RTL localization support.

Sequence diagram for RTL-aware translation lookup

sequenceDiagram
    participant UI as UILayer
    participant LM as LanguageManager

    UI->>LM: _(key="Face Enhancer", default=None)
    activate LM
    LM->>LM: text = translations.get(key, default or key)
    LM->>LM: normalized_lang = current_language.lower().split("-", 1)[0]
    alt normalized_lang in RTL_LANGUAGES
        alt text startswith RTL_MARK
            LM-->>UI: text
        else text does not startwith RTL_MARK
            LM->>LM: text = RTL_MARK + text
            LM-->>UI: text
        end
    else normalized_lang not in RTL_LANGUAGES
        LM-->>UI: text
    end
    deactivate LM

    UI->>UI: Create CTkLabel(text=translated_text)
Loading

File-Level Changes

Change Details Files
Add RTL support to translation lookup and normalize language codes in the language manager.
  • Define a set of RTL language codes and an RTL mark constant for prefixing text.
  • Update the translation lookup method to normalize the current language code to a base language and detect RTL locales.
  • Ensure returned translations for RTL languages are prefixed with the RTL mark if not already present, preserving existing marks when present.
  • Adjust the translation method docstring capitalization and behavior description.
modules/gettext.py
Localize remaining hard-coded UI labels for enhancer, transparency, sharpness, and mouth mask controls.
  • Replace hard-coded English label texts with translated strings obtained via the translation function, while preserving trailing colons in the rendered UI.
  • Ensure new labels integrate with the existing i18n plumbing by wrapping display text in the translation helper.
modules/ui.py
Introduce Hebrew locale resource file.
  • Add a new Hebrew locale JSON file to provide translations for UI strings, including the newly localized labels and RTL-mark-prefixed text where appropriate.
locales/he.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • In LanguageManager._, the non-RTL path currently falls through without a return, so you should add a final return text after the RTL-specific block to preserve the original behavior for LTR languages.
  • When checking for the existing RTL mark with text.startswith(RTL_MARK), consider trimming leading whitespace or using a more robust check, otherwise translations with leading spaces will be wrapped with a duplicate RTL mark.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `LanguageManager._`, the non-RTL path currently falls through without a `return`, so you should add a final `return text` after the RTL-specific block to preserve the original behavior for LTR languages.
- When checking for the existing RTL mark with `text.startswith(RTL_MARK)`, consider trimming leading whitespace or using a more robust check, otherwise translations with leading spaces will be wrapped with a duplicate RTL mark.

## Individual Comments

### Comment 1
<location path="modules/ui.py" line_range="436-439" />
<code_context>
         save_switch_states()

-    enhancer_label = ctk.CTkLabel(root, text="Face Enhancer:")
+    enhancer_label = ctk.CTkLabel(root, text=f'{_("Face Enhancer")}:')
     enhancer_label.place(relx=0.1, rely=0.62, relwidth=0.2, relheight=0.03)

</code_context>
<issue_to_address>
**suggestion:** Include punctuation in the translatable string to allow locale-specific placement.

Currently the colon is concatenated outside the translation (e.g. `_("Face Enhancer") + ":"`), which prevents locale-specific punctuation or placement (especially for RTL languages). Instead, pass the full label string to translation, e.g. `_("Face Enhancer:")`, so translators can control punctuation as needed.

Suggested implementation:

```python
    enhancer_label = ctk.CTkLabel(root, text=_("Face Enhancer:"))

```

```python
    transparency_label = ctk.CTkLabel(root, text=_("Transparency:"))

```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread modules/ui.py Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Hebrew localization support, including RTL text handling, and updates several UI labels to use translated strings.

Changes:

  • Added locales/he.json with Hebrew translations for existing UI strings.
  • Implemented RTL support in LanguageManager._() by prefixing RTL-mark for RTL languages.
  • Updated several CustomTkinter label strings to be translatable (Face Enhancer / Transparency / Sharpness / Mouth Mask).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.

File Description
modules/ui.py Converts a few hard-coded label texts into translated equivalents.
modules/gettext.py Adds RTL language detection + RTL mark insertion in the translation helper.
locales/he.json Introduces Hebrew translations for many UI strings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/ui.py Outdated
Comment thread modules/gettext.py Outdated
Comment thread modules/gettext.py Outdated
Comment thread modules/ui.py Outdated
Comment thread locales/he.json
Comment thread modules/ui.py Outdated
Comment thread modules/ui.py Outdated
Copilot AI and others added 2 commits March 28, 2026 18:18
…ons-pr-1711

Address PR hacksider#1711 review feedback for RTL localization and translatable UI labels
@lidorshimoni
Copy link
Copy Markdown
Author

lets merge :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants