Skip to content

Localization and Prompts

Puzzak edited this page Nov 20, 2026 · 1 revision

Localization & Prompts

PAIOS ships full multilingual UI + overlay localization in 6 languages alongside transparent, editable Markdown system prompts and Android SAF folder synchronization.


Supported Languages (6 Bundled Locales)

Defined in assets/translations/languages.json and registered in pubspec.yaml:

ID Language Native Name (origin) Notes
en English English Primary fallback locale
uk Ukrainian Українська Full app & overlay parity
zh Traditional Chinese 繁體中文 Resolved for Hant, TW, HK, MO
zh-Hans Simplified Chinese 简体中文 Added in v1.8.8 / completed in v1.8.9 (PR #36); resolved for Hans, CN, SG, MY
de German Deutsch Full app & overlay parity
tr Turkish Türkçe Full app & overlay parity

Script- & Region-Aware Chinese Resolution

Both Dictionary.resolveSupportedLocaleCode (Dart lib/parts/translator.dart) and MeshOverlayActivity.resolveOverlayLanguage (Kotlin) inspect full BCP-47 tags (languageCode, scriptCode, countryCode):

  • Hans, CN, SG, or MY -> zh-Hans
  • Hant, TW, HK, MO (or generic zh fallback) -> zh

3-Tier SWR Translation Engine & Mojibake Immunity

Dictionary (lib/parts/translator.dart) follows a 3-tier SWR strategy:

  1. Tier 1 — Bundled Assets (assets/translations/<id>.json): Always available offline at startup (and used exclusively in debug builds unless testing remote).
  2. Tier 2 — Hive Cache ('paios_storage'): Persists refreshed translations locally (cached_dict_<langId>).
  3. Tier 3 — Remote GitHub JSON: Fetches updated strings in release builds with a 5-second timeout and explicit utf8.decode(response.bodyBytes).

Mojibake Self-Healing

Dictionary.hasMojibake, repairMojibake, and sanitizeTranslationValue detect and repair CP1251 and Windows-1252 UTF-8 corruption (such as "…", "•", "—", "…", "РџСЂРёРІС–С‚") without false-positiving on legitimate Ukrainian text ("Рік", "Сім", "Рецепт"). Poisoned remote or cached strings can never overwrite clean bundled translations, and corrupted Hive cache entries self-heal on startup.


Slim Default System Prompt & Custom .md Prompts

2-Sentence system_default.md Baseline

Since v1.8.8, assets/prompts/system_default.md is intentionally kept to 2 sentences:

You are PAIOS, a helpful, private on-device AI assistant. Use query_aicore_documentation when asked who you are, to tell about yourself, or about PAIOS and AICore.

  • Both PromptRepository.initFromHive (Dart) and MeshOverlayActivity.resolveActivePersonaContent (Kotlin) always refresh the default persona from bundled assets so stale cached prompts cannot persist across updates.
  • Keeping the baseline minimal preserves maximum token headroom inside Gemini Nano's 4,096-token window while delegating detailed PAIOS self-knowledge to query_aicore_documentation on demand.

Android SAF UTF-8 .md Folder Sync

Users can create, edit, import, and export custom [USER INSTRUCTIONS] personas in Settings -> Prompts:

  • UTF-8 Export (FileAccessService.exportMd): Encodes .md files with explicit utf8.encode so multi-byte CJK/Ukrainian/German/Turkish text never truncates.
  • Unicode SAF Filenames (FileAccessService.nameToFilename): Preserves Unicode letters and digits (\p{L}\p{N}) when mapping persona names to .md filenames.
  • Immediate Folder Import: Selecting a linked folder via Android Storage Access Framework (pickPromptsFolder) triggers importAllFromLinkedFolder() automatically.

Related Pages: Offline Tooling & Built-in Documentation · Architecture & Model Variants · Building from Source

Clone this wiki locally