Skip to content

Add multi-language support with instant switching#23

Merged
StudentWeis merged 1 commit intoversion2from
copilot/add-multilanguage-support
Dec 29, 2025
Merged

Add multi-language support with instant switching#23
StudentWeis merged 1 commit intoversion2from
copilot/add-multilanguage-support

Conversation

Copy link
Contributor

Copilot AI commented Dec 29, 2025

Implements i18n system with English and Simplified Chinese. Users can switch languages in settings with immediate UI updates—no restart required.

Core Infrastructure

  • src/i18n/mod.rs: Language enum, TOML translation loader, compile-time embedding via include_str!()
  • assets/locales/{en,zh-CN}.toml: Externalized UI strings (52 translations each)
  • Settings: Added language field, persisted to config

UI Integration

All user-facing strings now use i18n.t(key):

  • Settings panel with language selector
  • Main board tooltips (Clear All, Pin/Unpin)
  • Tray menu items
  • Search placeholder

Language selection updates search placeholder immediately for instant feedback:

button.on_click(cx.listener(move |board, _, window, cx| {
    board.selected_language = index;
    // Instant preview
    if let Ok(temp_i18n) = I18n::new(lang_copy) {
        board.search_input.update(cx, |input, cx| {
            input.set_placeholder(temp_i18n.t("search_placeholder"), window, cx);
        });
    }
    cx.notify();
}))

Extensibility

New languages require: (1) add TOML file, (2) add enum variant, (3) update load_language() match arm.

Translation failures log warnings but gracefully fallback to [Missing: key] format.

Original prompt

添加一个多语言的功能。用户可以在设置中选择具体的语种。把各个语言的字符串以配置文件的形式存在。用户可以一键全局切换。


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@StudentWeis StudentWeis marked this pull request as ready for review December 29, 2025 01:17
Copilot AI changed the title [WIP] Add multilingual feature with language selection Add multi-language support with instant switching Dec 29, 2025
Copilot AI requested a review from StudentWeis December 29, 2025 01:24
feat: enhance i18n support
@StudentWeis StudentWeis force-pushed the copilot/add-multilanguage-support branch from faa8d21 to 9f7b700 Compare December 29, 2025 02:40
@StudentWeis StudentWeis merged commit 9f7b700 into version2 Dec 29, 2025
5 checks passed
@StudentWeis StudentWeis deleted the copilot/add-multilanguage-support branch December 29, 2025 02:47
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