Skip to content

Translations via string table#2

Open
popiel wants to merge 1 commit into
smartmita:mainfrom
popiel:main
Open

Translations via string table#2
popiel wants to merge 1 commit into
smartmita:mainfrom
popiel:main

Conversation

@popiel
Copy link
Copy Markdown

@popiel popiel commented May 4, 2026

Support both Chinese and English button labels and messages, based on the editor's locale setting.

Summary by Sourcery

Add locale-aware string table for the Copy All Errors editor plugin and localize its UI text and messages to English and Chinese based on the editor language.

New Features:

  • Introduce a string table to provide English and Chinese labels and messages for the Copy All Errors button and logs, selected according to the editor locale.

Enhancements:

  • Cache and detect the editor locale with fallbacks based on existing UI language to choose appropriate translations for plugin messages.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 4, 2026

Reviewer's Guide

Adds a locale-aware string table and translation helper to support English and Chinese UI text for the Copy All Errors plugin, wiring all user-facing strings to this mechanism and caching editor locale detection.

Sequence diagram for locale detection and button injection

sequenceDiagram
    participant GodotEditor
    participant EditorInterface
    participant CopyAllErrorsPlugin
    participant ErrorPanel
    participant CopyButton

    GodotEditor->>CopyAllErrorsPlugin: _enter_tree()
    activate CopyAllErrorsPlugin
    CopyAllErrorsPlugin->>CopyAllErrorsPlugin: _schedule_retry()
    CopyAllErrorsPlugin->>CopyAllErrorsPlugin: _find_error_panel(root)
    CopyAllErrorsPlugin->>ErrorPanel: scan_children()
    ErrorPanel-->>CopyAllErrorsPlugin: Button ExpandAll_or_全部展开
    CopyAllErrorsPlugin->>CopyAllErrorsPlugin: set _detected_ui_is_english
    CopyAllErrorsPlugin->>CopyAllErrorsPlugin: _inject_copy_button()
    activate CopyAllErrorsPlugin
    CopyAllErrorsPlugin->>CopyAllErrorsPlugin: _tr(button_text)
    CopyAllErrorsPlugin->>CopyAllErrorsPlugin: _get_locale()
    alt editor language available
        CopyAllErrorsPlugin->>EditorInterface: get_editor_language()
        EditorInterface-->>CopyAllErrorsPlugin: editor_lang
        CopyAllErrorsPlugin->>CopyAllErrorsPlugin: cache locale from editor_lang
    else editor language not available
        CopyAllErrorsPlugin->>CopyAllErrorsPlugin: locale = en or zh from _detected_ui_is_english
    end
    CopyAllErrorsPlugin-->>CopyButton: set text and tooltip via _tr
    deactivate CopyAllErrorsPlugin
    GodotEditor-->>CopyAllErrorsPlugin: editor ready
Loading

Class diagram for localized CopyAllErrors plugin structure

classDiagram
    class CopyAllErrorsPlugin {
        <<EditorPlugin>>
        +const _STRINGS
        +const _MAX_RETRIES
        -Button _copy_button
        -Tree _error_tree
        -HBoxContainer _hbox
        -Timer _setup_timer
        -int _retry_count
        -String _cached_locale
        -bool _detected_ui_is_english
        +void _enter_tree()
        +void _exit_tree()
        +String _get_locale()
        +String _tr(key)
        +void _schedule_retry()
        +Dictionary _find_error_panel(node)
        +void _inject_copy_button()
        +void _on_copy_all_pressed()
        +void _flash_button(msg)
        +String _get_type_char(item)
    }

    EditorPlugin <|-- CopyAllErrorsPlugin
Loading

File-Level Changes

Change Details Files
Introduce locale-aware string table and translation helper used for all user-facing text.
  • Add _STRINGS dict containing English and Chinese variants for button labels, tooltips, log/warning messages, and flash messages.
  • Add _cached_locale and _detected_ui_is_english state used to cache the resolved locale and detect UI language heuristically.
  • Implement _get_locale() to resolve locale from EditorInterface.get_editor_language() with prefix matching and fallback based on detected UI language.
  • Implement _tr() helper to lookup strings by key with English fallback when missing.
addons/copy_all_errors/plugin.gd
Wire plugin behavior to use translated strings instead of hard-coded Chinese text and improve some comments.
  • Use _tr() for warning when the debugger error panel is not found.
  • Detect whether the editor UI is English or Chinese based on existing 'Expand All' / '全部展开' button when scanning the error panel.
  • Use _tr() for injected copy button text and tooltip.
  • Use _tr() for messages shown when the error tree is invalid, when there is nothing to copy, and when reporting copied counts in logs and flash messages.
  • Tweak comments (e.g., icon comment and metadata comment) and reset cached locale on _exit_tree().
addons/copy_all_errors/plugin.gd
No-op change in plugin configuration file.
  • Retain script path assignment in plugin.cfg with no effective change (whitespace-only / re-save).
addons/copy_all_errors/plugin.cfg

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

@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 reviewed your changes and they look great!


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.

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.

1 participant