How elinchi/emctranslator works
Purpose and Entry Points
EMCT is a desktop GUI for translating Minecraft localization JSON, including language files extracted from mod JARs. It supports manual editing, AI-assisted translation, project persistence, previews, and resource-pack export.
• Application launcher: Minecraft-Translator-GUI-last.py
• Main orchestration/window layer: program/app/window.py
• Build script for distribution: build.ps1
Application Orchestration and UI
The main window owns user-driven workflow: opening source files, switching projects/mods, invoking translation, updating editor state, and coordinating persistence/export. GUI controllers separate interactive behaviors from core services.
• Main window: program/app/window.py
• Translation UI interaction: program/gui/translation_controller.py
• Multi-project UI: program/gui/multiproject_panel.py
Preview behavior is isolated so the editor can render raw JSON-oriented output or Minecraft-style formatted text without making rendering part of translation storage.
• Preview coordination: program/gui/preview_controller.py
• Minecraft text rendering: program/gui/mc_renderer.py
Translation Domain and Validation
Translation state consists of source keys/original values and editable translated values. Translation processing preserves Minecraft formatting requirements through validation of placeholders and escape sequences before output is accepted.
• Translation model/logic: program/core/translation.py
• Translation workflow service: program/core/translation_service.py
• Format validation: program/core/validation.py
The UI controller is the boundary between row-level editing/ghost suggestions and domain operations; persistent project and cache services should not depend on GUI widgets.
AI Provider Boundary
AI work is provider-specific behind the program/ai layer. A worker coordinates translation execution, while DeepL and Ollama adapters handle their respective external interfaces.
• Translation worker: program/ai/worker.py
• DeepL integration: program/ai/deepl.py
• Ollama integration: program/ai/ollama.py
DeepL requires an API key and tracks usage; Ollama relies on a locally available ollama CLI and selected model. Provider/model/key preferences are retained in cache/config state.
Input, Projects, and Cache Persistence
Source localization can be loaded from standalone JSON or from JAR archives. Projects use .mctproj files to persist translation state, preview state, and project-local cache; loading merges project cache with global cache without replacing existing global entries.
• JSON read/write: program/core/json_io.py
• JAR extraction/access: program/core/jar_io.py
• Project lifecycle: program/core/project_service.py
• Project serialization: program/core/project_store.py
• Global translation memory/cache: program/core/cache.py
The durable global cache is intended for %LOCALAPPDATA%/EMCT/translation_cache.json; tracked cache JSON files such as program/app/translation_cache.json are repository-side artifacts/defaults rather than the intended user-state location.
Multi-Project Resource-Pack Pipeline
Multi-project mode scans mod JARs recursively, selects those with usable language JSON and no existing Ukrainian translation, and maintains each mod’s translation state in memory while switching items. Export combines completed translations into Minecraft resource-pack paths such as assets/<namespace>/lang/uk_ua.json.
• Multi-project state/workflow: program/core/multiproject_service.py
• Resource-pack assembly: program/core/resource_pack.py
• JAR discovery/extraction: program/core/jar_io.py
This is the main aggregation boundary: individual project/mod translations are edited independently, then emitted together as one resource pack.
Runtime Assets and Localization
The application is Python-based with dependencies declared in requirements.txt. Its desktop UI includes bundled fonts and audio feedback, while interface localization is data-driven through language JSON.
• Dependencies: requirements.txt
• UI localization loader: program/config/i18n.py
• Language catalogs: program/config/lang/en_us.json, program/config/lang/uk_ua.json
• Audio assets: program/sounds/click.wav
Main entry points: window.py Main window · project_service.py Project lifecycle · translation_service.py Translation service · multiproject_service.py Multi-project service
Components 22
Desktop UI
- Main window · Owns user workflows, editor state, persistence, and export coordination.
program/app/window.py - Translation controller · Bridges row editing and ghost suggestions to domain operations.
program/gui/translation_controller.py - Multi-project panel
program/gui/multiproject_panel.py - Preview controller
program/gui/preview_controller.py - Minecraft text renderer · Renders Minecraft-style formatted text separately from stored translations.
program/gui/mc_renderer.py - UI localization · Loads English and Ukrainian interface catalogs.
program/config/i18n.py
Translation Core
- Translation model · Holds source keys, originals, and editable translations.
program/core/translation.py - Translation service · Processes translations and accepts validated output.
program/core/translation_service.py - Format validation · Preserves placeholders and escape sequences.
program/core/validation.py
Projects & Export
- JSON I/O
program/core/json_io.py - JAR I/O · Reads localization JSON from mod archives.
program/core/jar_io.py - Project lifecycle
program/core/project_service.py - Project store · Persists .mctproj state and project-local cache.
program/core/project_store.py - Translation cache · Durable user cache is stored under LOCALAPPDATA.
program/core/cache.py - Multi-project service · Maintains independent mod translation states while switching projects.
program/core/multiproject_service.py - Resource-pack exporter · Writes completed translations to assets/<namespace>/lang/uk_ua.json.
program/core/resource_pack.py
AI Providers
- AI translation worker
program/ai/worker.py - DeepL adapter · Uses API key and tracks usage.
program/ai/deepl.py - Ollama adapter · Invokes the local ollama CLI with a selected model.
program/ai/ollama.py
Other components
- Application launcher
Minecraft-Translator-GUI-last.py - Distribution build
build.ps1 - Python dependencies
requirements.txt
Connections 24
- Application launcher → Main window: starts
- Main window → Translation controller: coordinates editing
- Main window → Multi-project panel: hosts
- Main window → Preview controller: updates
- Preview controller → Minecraft text renderer: renders formatted preview
- Translation controller → Translation service: invokes
- Translation service → Translation model: updates
- Translation service → Format validation: validates output
- Translation service → AI translation worker: requests AI translation
- AI translation worker → DeepL adapter: uses
- AI translation worker → Ollama adapter: uses
- AI translation worker → Translation cache: reads provider preferences
- Main window → Project lifecycle: opens and saves projects
- Project lifecycle → Project store: serializes
- Project lifecycle → Translation cache: merges project cache
- Project lifecycle → JSON I/O: reads source JSON
- Project lifecycle → JAR I/O: loads JAR localization
- Multi-project panel → Multi-project service: drives
- Multi-project service → JAR I/O: scans mod JARs
- Multi-project service → Translation model: maintains per-mod state
- Multi-project service → Resource-pack exporter: exports completed mods
- Main window → UI localization: loads UI language
- Distribution build → Application launcher: packages
- Python dependencies → Application launcher: runtime requirements