Instruction file imported from ifer47/markeron (
.cursor/rules/i18n.mdc). Copyright stays with the author.
Internationalization (i18n)
MarkerOn has two string layers. Changing user-visible text may require both.
1. Frontend (Vue UI)
| File | Locale |
|---|---|
src/i18n/en.ts |
English |
src/i18n/zh-CN.ts |
简体中文 |
- Always edit both files with the same key structure (dot-path nested objects).
- Use
useI18n()→t('section.key')in components; never hardcode UI strings. - Optional vars:
t('key', { name: value })replaces{name}in the string. - Register new locales in
src/i18n/index.ts(messagesmap +availableLocales).
Checklist (new/changed UI copy)
- Add key to
en.tsandzh-CN.ts - Replace literal text in Vue with
t('…') - If key is user-facing, add a case in
src/i18n/index.test.ts(optional but preferred)
2. Backend (Rust — tray, shortcuts labels, window title)
| File | Purpose |
|---|---|
src-tauri/src/i18n.rs |
Strings struct: settings, help, about, quit, window_title, toggle_drawing, clear_drawing |
- Only zh / en (boolean
USE_CHINESE), not full dot-path i18n. i18n::init()on startup from saved locale;i18n::set_locale()on language change.- After locale change,
save_localecommand rebuilds tray menu and updates settings window title.
When to touch i18n.rs
- New tray menu item label
- Renamed system-facing shortcut description shown in settings
- Settings window title string
Locale persistence flow
GeneralTab changeLocale → setLocale (frontend) → invoke('save_locale')
→ config.json + i18n::set_locale + rebuild_tray_menu + set_title
Commit type
Use i18n: prefix when the change is primarily translation/copy (feeds 🧹 Improvements in release notes).