Skip to content

feat(i18n): implement dynamic locale loading, local JSON imports, and customized window title#1043

Open
Thanhdv2007 wants to merge 1 commit into
BigPizzaV3:mainfrom
Thanhdv2007:feature/i18n-vietnamese-manager
Open

feat(i18n): implement dynamic locale loading, local JSON imports, and customized window title#1043
Thanhdv2007 wants to merge 1 commit into
BigPizzaV3:mainfrom
Thanhdv2007:feature/i18n-vietnamese-manager

Conversation

@Thanhdv2007

@Thanhdv2007 Thanhdv2007 commented Jun 16, 2026

Copy link
Copy Markdown

Description

This Pull Request implements a comprehensive, dynamic internationalization (i18n) management system for Codex++ Manager. Instead of compile-time static translations, this system enables runtime loading, hot-swapping, and user-importing of translation resource files (.json) directly from the disk.

Key Changes

1. Backend (Rust / Tauri)

  • Dynamic Locale Loading (load_custom_locales command): Scans the locales/ directory located adjacent to the executable binary. Any valid .json locale files found are loaded into the frontend dynamically at startup.
  • Locale Import Dialog (import_custom_locale command): Exposes a secure Tauri API triggering a native OS file dialog. Users can select any local translation JSON file, which is then parsed, validated, and copied into the application's locales/ directory for persistence.
  • Tauri Command Registration: Properly registered commands in src-tauri/src/lib.rs.

2. Frontend (React / i18next)

  • Custom Dropdown Selector:
    • Replaced the generic HTML select box with a styled, responsive React dropdown component.
    • Optimized width (fixed at ~85px) and simplified display to uppercase locale codes (e.g., ZH, EN, VI).
    • Implemented clicking outside detection to automatically close the dropdown menu.
    • Applied position: "relative" and z-index: 50 on the topbar header to prevent the dropdown from being clipped or covered by the layout view below.
  • On-the-fly Bundle Injection: The React app listens for imported locales, registers the bundle dynamically using i18nInstance.addResourceBundle, and switches the active language immediately without requiring a restart.
  • Dynamic Window Title:
    • Added a useEffect that listens for language changes and updates the Tauri window title dynamically.
    • Configured default window title in tauri.conf.json as Codex++ Manager (neutral start), updating to "Codex++ 管理工具" for Chinese (ZH) and "Codex++ Manager" for English (EN), Vietnamese (VI) or any other imported language.

3. Preset & Provider Localization

  • Refactored static category label maps inside ProviderPresetSelector.tsx to read translation keys dynamically.
  • Localized static branding strings for model providers (e.g., Volcengine, Baidu, Xiaomi) in presets.ts.
  • Completely translated remaining UI elements to English and Vietnamese.

Verification & Build Status

  • Ran npm run check (TypeScript verification) - PASSED
  • Ran npm run vite:build (Vite production bundle build) - PASSED
  • Ran cargo check (Rust compilation verification) - PASSED

@Thanhdv2007 Thanhdv2007 changed the title feat(i18n): support dynamic locale loading and custom dropdown feat(i18n): implement dynamic locale loading, local JSON imports, and customized window title Jun 16, 2026
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