Localization & Internationalization
Local GPT supports 11 languages out of the box, with automatic language detection and a community-driven translation system.Supported Languages
The plugin includes complete translations for:English
en - Default languageGerman
de - DeutschSpanish
es - EspañolFrench
fr - FrançaisItalian
it - ItalianoJapanese
ja - 日本語Korean
ko - 한국어Dutch
nl - NederlandsPortuguese
pt - PortuguêsRussian
ru - РусскийChinese
zh - 中文Language Detection
Local GPT uses Obsidian’s language setting automatically. The active language is determined by:How Language Detection Works
For advanced use cases like detecting the language of user content, Local GPT includes a sophisticated language detection system insrc/languageDetection.ts.
Script-Based Detection
The system first checks for distinctive writing systems:Japanese (Hiragana, Katakana)
Japanese (Hiragana, Katakana)
Detects Unicode ranges:
U+3040 - U+309F: HiraganaU+30A0 - U+30FF: KatakanaU+31F0 - U+31FF: Katakana Phonetic ExtensionsU+FF65 - U+FF9F: Halfwidth Katakana
Chinese (Han Characters)
Chinese (Han Characters)
Detects Unicode ranges:
U+3400 - U+4DBF: CJK Unified Ideographs Extension AU+4E00 - U+9FFF: CJK Unified Ideographs
When Japanese text contains Han characters (Kanji), they are counted as Japanese if Hiragana/Katakana is also present.
Korean (Hangul)
Korean (Hangul)
Detects Unicode ranges:
U+1100 - U+11FF: Hangul JamoU+3130 - U+318F: Hangul Compatibility JamoU+AC00 - U+D7AF: Hangul Syllables
Russian/Cyrillic
Russian/Cyrillic
Detects Unicode ranges:
U+0400 - U+04FF: CyrillicU+0500 - U+052F: Cyrillic SupplementU+2DE0 - U+2DFF: Cyrillic Extended-AU+A640 - U+A69F: Cyrillic Extended-B
The
ru code represents Cyrillic script used by Russian, Ukrainian, Bulgarian, Serbian, and other languages. The detector identifies the script, not the specific language.Other Scripts
Other Scripts
Also supports:
- Arabic (
ar):U+0600 - U+06FF,U+0750 - U+077F,U+08A0 - U+08FF - Hebrew (
he):U+0590 - U+05FF - Greek (
el):U+0370 - U+03FF,U+1F00 - U+1FFF - Hindi/Devanagari (
hi):U+0900 - U+097F
Latin-Script Detection
For Latin-based languages (English, Spanish, French, etc.), the system uses: Character-based scoring:- Distinctive diacritics (ñ, ü, ç, õ, etc.)
- Weight: 3 points per character
- Common words (“the”, “der”, “le”, “el”, etc.)
- Weight: 2 points per occurrence
Performance Optimization
- Only the first 1,000 characters are analyzed
- Latin language detection requires at least 10 letters to avoid false positives on short text
Translation System
The i18n system is implemented insrc/i18n/index.ts:
Translation File Structure
Translations are stored insrc/i18n/*.json files:
Using Translations
In the code, translations are accessed via dot notation:Contributing Translations
We welcome community contributions to improve translations or add new languages!Fork the Repository
Visit github.com/pfrankov/obsidian-local-gpt and fork it.
Choose a Language
To improve an existing translation, edit
src/i18n/[code].json.To add a new language:- Copy
src/i18n/en.jsontosrc/i18n/[code].json - Add the import in
src/i18n/index.ts:
- Add to the locales object:
Translate Strings
Translate all string values in the JSON file. Keep:
- JSON structure identical
- Placeholder variables like
{{message}}unchanged - Emoji prefixes (💡, 🎨, 🚀) if they add meaning
Test Your Translation
- Build the plugin:
npm run build - Change Obsidian’s language to your locale
- Verify all UI strings appear correctly
Translation Guidelines
Keep Placeholders Intact
Keep Placeholders Intact
Placeholders like ❌ Incorrect:
{{message}}, {{name}}, {{percent}} must remain unchanged:✅ Correct:Preserve JSON Structure
Preserve JSON Structure
Do not change key names, only values:✅ Correct:❌ Incorrect:
Handle Emojis Thoughtfully
Handle Emojis Thoughtfully
Emojis can be kept, adapted, or removed based on cultural appropriateness:Option 1 - Keep:Option 2 - Adapt:Option 3 - Remove:
Test Edge Cases
Test Edge Cases
Verify your translations work in:Should work with both short names (“Fix”) and long names (“Summarize this document in detail”).
- Long text: Does it fit in the UI?
- Short text: Is it still clear?
- With placeholders: Does the sentence flow naturally?
Fallback Behavior
If a translation key is missing:- The system logs a warning:
Translation missing: [key] - Falls back to English (
en) - If English is also missing, returns the raw key
Community Actions Localization
Community actions can be filtered by language in the settings:- Setting:
settings.communityActionsLanguage - Default: Matches Obsidian’s active language
- Purpose: Shows community-contributed actions in your language
Source Code References
i18n System
src/i18n/index.ts - Translation loader and interpolationLanguage Detection
src/languageDetection.ts - Content language detectionTranslation Files
src/i18n/*.json - All language filesEnglish (Reference)
src/i18n/en.json - Base translation fileNext Steps
Contributing Guide
Learn how to contribute to the project
Troubleshooting
Debug language detection and display issues