Skip to content

Feature/french UI language#59

Open
1jifang wants to merge 5 commits intoQuellaMC:mainfrom
1jifang:feature/French-UI-Language
Open

Feature/french UI language#59
1jifang wants to merge 5 commits intoQuellaMC:mainfrom
1jifang:feature/French-UI-Language

Conversation

@1jifang
Copy link
Contributor

@1jifang 1jifang commented Oct 14, 2025

This pull request focuses on improving internationalization and error handling for translation features. The main changes are the centralization of error messages into locale files, the addition of French language support, and refactoring how localized error messages are retrieved.

Internationalization improvements:

  • Centralized translation error messages (errTranslationApi, errTranslationRequest, errTranslationGeneric) into all locale files (_locales/en/messages.json, _locales/es/messages.json, _locales/ja/messages.json, _locales/ko/messages.json, _locales/zh_CN/messages.json, _locales/zh_TW/messages.json) for consistent and maintainable error messaging across supported languages. [1] [2] [3] [4] [5] [6]
  • Added French (fr) as a supported UI language in language detection logic (config/configSchema.js, content_scripts/shared/subtitleUtilities.js) and in the language selection dropdown (options/components/sections/GeneralSection.jsx). [1] [2] [3]

Error message handling refactor:

  • Removed hardcoded localizedErrorMessages from subtitleUtilities.js and updated getLocalizedErrorMessage to use Chrome's i18n API for fetching error messages, ensuring messages are always up-to-date with locale files. [1] [2]

Other:

  • Added a comment for testing purposes in translation_providers/geminiVertexTranslate.js (no functional impact).

Summary by Sourcery

Centralize translation error messages into locale files, introduce French UI language support, and refactor error message retrieval to use Chrome’s i18n API.

New Features:

  • Add French as a supported UI language

Enhancements:

  • Centralize translation error messages in locale files for consistent multilingual messaging
  • Refactor getLocalizedErrorMessage to use Chrome’s i18n API instead of hardcoded messages

Documentation:

  • Introduce French translation JSON file in locales

Chores:

  • Add a temporary test comment in geminiVertexTranslate.js

- Add _locales/fr/messages.json
- Add Français to UI selector
- Detect fr in browser language
- Support fr in shared error messages
…anguages

- Introduced new error messages for translation API errors, request errors, and generic translation failures in English, Spanish, French, Japanese, Korean, Simplified Chinese, and Traditional Chinese.
- Updated localization files to enhance user feedback during translation issues.
Copilot AI review requested due to automatic review settings October 14, 2025 20:26
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 14, 2025

Reviewer's Guide

This PR refactors translation error handling by removing hardcoded messages and leveraging Chrome’s i18n API with centralized locale entries (now including French), and extends UI language support by adding French in detection logic and the settings dropdown.

Entity relationship diagram for locale message files with new French support

erDiagram
    EN_MESSAGES {
        errTranslationApi VARCHAR
        errTranslationRequest VARCHAR
        errTranslationGeneric VARCHAR
    }
    ES_MESSAGES {
        errTranslationApi VARCHAR
        errTranslationRequest VARCHAR
        errTranslationGeneric VARCHAR
    }
    JA_MESSAGES {
        errTranslationApi VARCHAR
        errTranslationRequest VARCHAR
        errTranslationGeneric VARCHAR
    }
    KO_MESSAGES {
        errTranslationApi VARCHAR
        errTranslationRequest VARCHAR
        errTranslationGeneric VARCHAR
    }
    ZH_CN_MESSAGES {
        errTranslationApi VARCHAR
        errTranslationRequest VARCHAR
        errTranslationGeneric VARCHAR
    }
    ZH_TW_MESSAGES {
        errTranslationApi VARCHAR
        errTranslationRequest VARCHAR
        errTranslationGeneric VARCHAR
    }
    FR_MESSAGES {
        errTranslationApi VARCHAR
        errTranslationRequest VARCHAR
        errTranslationGeneric VARCHAR
    }
    EN_MESSAGES ||--|| ES_MESSAGES : same keys
    EN_MESSAGES ||--|| JA_MESSAGES : same keys
    EN_MESSAGES ||--|| KO_MESSAGES : same keys
    EN_MESSAGES ||--|| ZH_CN_MESSAGES : same keys
    EN_MESSAGES ||--|| ZH_TW_MESSAGES : same keys
    EN_MESSAGES ||--|| FR_MESSAGES : same keys
Loading

Class diagram for updated error message handling in subtitleUtilities.js

classDiagram
    class subtitleUtilities {
        +getUILanguage()
        +getLocalizedErrorMessage(errorTypeKey, details)
    }
    subtitleUtilities : -getUILanguage() updated to support 'fr'
    subtitleUtilities : -getLocalizedErrorMessage() refactored to use chrome.i18n.getMessage()
Loading

File-Level Changes

Change Details Files
Centralize translation error messages in locale files and refactor retrieval
  • Added errTranslation* entries to all existing locale JSONs and created fr/messages.json
  • Removed hardcoded localizedErrorMessages object in subtitleUtilities.js
  • Introduced keyMap and updated getLocalizedErrorMessage to call chrome.i18n.getMessage
  • Simplified fallback behavior to rely on locale resolution
content_scripts/shared/subtitleUtilities.js
_locales/en/messages.json
_locales/es/messages.json
_locales/ja/messages.json
_locales/ko/messages.json
_locales/zh_CN/messages.json
_locales/zh_TW/messages.json
_locales/fr/messages.json
Add French support to language detection and UI
  • Extended getUILanguage and detectBrowserLanguage to return 'fr'
  • Inserted French option in the GeneralSection language dropdown
content_scripts/shared/subtitleUtilities.js
config/configSchema.js
options/components/sections/GeneralSection.jsx
Add non-functional test comment
  • Inserted testing comment in geminiVertexTranslate.js (no functional impact)
translation_providers/geminiVertexTranslate.js

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
Contributor

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

This PR enhances internationalization support by adding French as a supported UI language and centralizing error message handling through locale files. The changes remove hardcoded error messages and improve consistency across all supported languages.

  • Added French language support throughout the application
  • Centralized translation error messages into locale files for all supported languages
  • Refactored error message retrieval to use Chrome's i18n API instead of hardcoded messages

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
translation_providers/geminiVertexTranslate.js Added test comment (no functional impact)
options/components/sections/GeneralSection.jsx Added French language option to UI language dropdown
content_scripts/shared/subtitleUtilities.js Removed hardcoded error messages and updated getLocalizedErrorMessage to use Chrome i18n API
config/configSchema.js Added French language detection support
_locales/*/messages.json Added centralized error message translations for all supported languages
_locales/fr/messages.json Complete French translation file for the entire application

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
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 there - I've reviewed your changes - here's some feedback:

  • Remove the leftover testing comment in translation_providers/geminiVertexTranslate.js to avoid clutter.
  • Instead of returning an empty string when getLocalizedErrorMessage fails, include a sensible fallback (e.g., default English message) so users still see an error.
  • Verify that the new fr/messages.json contains translations for errTranslationApi, errTranslationRequest, and errTranslationGeneric to prevent missing locale entries.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Remove the leftover testing comment in translation_providers/geminiVertexTranslate.js to avoid clutter.
- Instead of returning an empty string when getLocalizedErrorMessage fails, include a sensible fallback (e.g., default English message) so users still see an error.
- Verify that the new fr/messages.json contains translations for errTranslationApi, errTranslationRequest, and errTranslationGeneric to prevent missing locale entries.

## Individual Comments

### Comment 1
<location> `content_scripts/shared/subtitleUtilities.js:303-312` </location>
<code_context>
-const localizedErrorMessages = {
</code_context>

<issue_to_address>
**issue (bug_risk):** Removing hardcoded localized error messages may impact fallback behavior if i18n is unavailable.

Since the function now returns an empty string if chrome.i18n fails, users may not see any error message. Please add a basic fallback to ensure error feedback is always displayed.
</issue_to_address>

### Comment 2
<location> `content_scripts/shared/subtitleUtilities.js:338` </location>
<code_context>
-        fallbackMessages['en'] ||
-        '[Translation Error]'
-    );
+    return '';
 }

</code_context>

<issue_to_address>
**issue (bug_risk):** Returning an empty string as a fallback may lead to silent failures in the UI.

If chrome.i18n is unavailable, return a generic error message instead of an empty string to ensure users receive feedback.
</issue_to_address>

### Comment 3
<location> `translation_providers/geminiVertexTranslate.js:23` </location>
<code_context>
         'vertexModel',
     ]);
     // test gpg sign
+    //test the sign again what is going on

     const model = config.vertexModel || 'gemini-2.5-flash';
</code_context>

<issue_to_address>
**nitpick:** Comment added appears to be a debugging note; consider removing or clarifying.

The comment lacks context and could confuse future maintainers. Please remove it if unnecessary, or clarify its relevance.
</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.

…errorTypeKey instead of an empty string, improving error handling.

- Removed outdated comments in geminiVertexTranslate.js for better code clarity.
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.

2 participants