Skip to content

feat(store): Add native in-app translation for module catalogue and descriptions - #1097

Open
socalschi wants to merge 1 commit into
JingMatrix:masterfrom
socalschi:feat/auto-translate-store
Open

socalschi wants to merge 1 commit into
JingMatrix:masterfrom
socalschi:feat/auto-translate-store

Conversation

@socalschi

Copy link
Copy Markdown
### Summary
This PR introduces native, in-app translation support for the Module Store, allowing users around the world to
read module titles, summaries, and full README/HTML descriptions in their preferred language.

### Key Features
1. **Configurable Target Language:**
   - Adds an **"Auto-translate store"** toggle in the Appearance & Language bottom sheet.
   - Adds a **"Translation language"** selector allowing users to follow the app's current locale or explicitly
   choose a target language (e.g., `pt`, `en`, `es`, `zh-CN`, etc.).

2. **Persistent Disk Caching (`store_translations_cache.json`):**
   - Implemented persistent atomic disk caching on `Dispatchers.IO` in `context.cacheDir`.
   - Translations survive process termination and app restarts without repeating network requests or flickering.

3. **Multi-tier Translation Pipeline:**
   - **Tier 1 (Instant offline):** Pre-bundled offline dictionary for instant rendering of the most common store
   modules.
   - **Tier 2 (Batch online):** Efficient coroutine-based parallel translation for uncached titles and summaries.
   - **Tier 3 (README/HTML chunking):** Granular text-node translation preserving HTML/Markdown tag structure,
   code blocks, URLs, and formatting intact.

4. **Synchronous Settings Commit:**
   - Language preferences use synchronous `.commit()` to ensure user preferences are not lost when closing the
   app via recent tasks.

### Verification
- Tested on Android 15 (PixelOS / arm64-v8a).
- Verified catalog translation, language switching, and persistence across process kills (`am force-stop`).
- Verified all code formatting complies with `./gradlew ktfmtFormat`.

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