I18N.md

Internationalization (i18n) Guide

This document explains how language support works in the Beledarians LM Studio Toolbox plugin and how to add new locale translations.


Supported Languages

Locale IDLanguageScript
enEnglishLatin
zh-CNChinese (Simplified)简体中文
zh-TWChinese (Traditional)繁體中文
deGermanLatin

Architecture: Dual-Layer Language Mechanism

The plugin uses a two-layer system to work around an architectural constraint in the LM Studio SDK: context.withConfigSchematics() can only be called once at plugin startup and cannot be updated afterwards.

Layer 1 — Config UI Language (Static, Boot-Time)

  • What it covers: All displayName and subtitle labels visible in the LM Studio plugin settings panel.
  • How it works: On startup, src/locales/i18n.ts detects the host OS language using:
    • Intl.DateTimeFormat().resolvedOptions().locale (primary — reliable on Windows/macOS)
    • POSIX environment variables LC_ALL, LANGUAGE, LANG (fallback — for headless Linux/llmster)
  • When it changes: Only on plugin restart. Changing OS language while LM Studio is running has no effect until the plugin process is restarted.

Layer 2 — Message Language (Dynamic, Per-Turn)

  • What it covers: All runtime text — delegation hints injected into prompts, plan mode instructions, retrieval status messages, citation prefixes/suffixes, document injection text.
  • How it works: A "Message Language" dropdown is exposed in the plugin settings (part of Layer 1). On every user message, promptPreprocessor.ts reads the current value of this dropdown and looks up the matching dictionary.
  • When it changes: Immediately — on the very next user message, with no plugin restart required.

Example Scenarios

OS LanguageMessage Language DropdownResult
zh-TWzh-TWFull Traditional Chinese UI and runtime text
en-USzh-CNEnglish config panel, Simplified Chinese runtime hints
de-DEenGerman config panel, English runtime hints

File Structure

src/locales/
├── types.ts    ← Shared LocaleDict TypeScript interface (source of truth)
├── i18n.ts     ← Detection, resolution, lookup engine
├── en.ts       ← English dictionary
├── zh-CN.ts    ← Simplified Chinese dictionary
├── zh-TW.ts    ← Traditional Chinese dictionary
└── de.ts       ← German dictionary

Adding a New Language

  • Create the dictionary file — copy src/locales/en.ts to src/locales/<locale>.ts (e.g., fr.ts).
  • Translate every value — the TypeScript interface in types.ts enforces that all keys are present. The build (npx tsc --noEmit) will fail if any key is missing.
  • Register the locale — open src/locales/i18n.ts and add two things:
    • Import: import { fr } from "./fr";
    • Add to the LOCALES registry: "fr": fr
  • Add detection routing — in the resolveLocale() function, add a pattern match for the new locale's IETF tag (e.g., if (tag.startsWith("fr")) return "fr";).
  • Run the type check: npx tsc --noEmit

Chinese Locale Notes

Sinophone Variant Routing

The resolveLocale() function maps the following OS tags:

System TagRoutes to
zh-TW, zh-HK, zh-MO, zh-Hantzh-TW
zh-CN, zh-Hans, zh-SG, zhzh-CN

Both dictionaries ship as full, independent translations — there is no silent fallback between zh-CN and zh-TW. Each receives its own complete string set appropriate to its regional vocabulary.

For RAG features with Chinese-language documents, the default nomic-ai/nomic-embed-text-v1.5-GGUF model has degraded performance on multi-byte Chinese characters. The zh-CN and zh-TW config subtitles explicitly recommend:

BAAI/bge-m3-gguf

Additionally, for Chinese documents, lowering the Retrieval Affinity Threshold to 0.35–0.45 (from the default 0.5) typically improves recall on Chinese technical text.


Contributing Translations

To contribute a translation or correction:

  • Fork the repository.
  • Create or update a locale file under src/locales/.
  • Run npx tsc --noEmit to confirm zero type errors.
  • Open a Pull Request with a description of the changes.

Chinese (zh-CN / zh-TW) review from native speakers is particularly welcome — please open an issue or PR if you spot unnatural phrasing in technical terms.