Localization & Translation Engine
Relevant source files
The following files were used as context for generating this wiki page:
The Localization & Translation Engine manages the conversion of game content between English and Russian, specifically focusing on user interface elements, changelogs, and entity naming conventions. It provides structural validation for translated strings and a framework for rendering multi-language content within the TGUI interface. Sources: modular_bandastation/translations/schema.json, tgui/packages/tgui/interfaces/ChangelogBandaStation.jsx
Translation Validation Logic
The engine enforces strict linguistic rules for Russian translations, particularly for entity names. This ensures that translated names remain consistent with the project's stylistic requirements.
Name Validation Criteria
The validation system checks several parameters for Russian names:
- Alphabetical Constraints: Names must use the Russian alphabet.
- Capitalization: The system identifies incorrect casing (e.g., lowercase starts where uppercase is required).
- Structural Integrity: It detects missing spaces, improper use of the "ё" character, and illegal characters.
- Grammar: The engine checks for common I-before-E typos and specific misspelling of technical terms like "Nanotrasen" or "CentCom".
Sources: modular_bandastation/translations/validate_ru_names.py:1-50, tools/ci/check_grep.sh:65-90
Validation Workflow
The following diagram illustrates how the validation script processes strings to ensure Russian linguistic accuracy.
The script validate_ru_names.py acts as a linting tool to prevent improper Russian strings from entering the codebase. Sources: modular_bandastation/translations/validate_ru_names.py
TGUI Localization Framework
The user interface utilizes React-based components to render localized text. Interfaces often include hardcoded Russian strings or fetch localized assets dynamically.
Localized Interface Components
The Malf AI interface (AntagInfoMalf.tsx) demonstrates localized section titles and descriptions directly in the UI code.
| Component Section | Localized Title (RU) | Description |
|---|---|---|
| Introduction | Вступление | Displays primary objectives. |
| Diagnostics | Диагностика | Shows system integrity and moral core reports. |
| Codewords | Кодовые слова | Contains Syndicate phrases and responses. |
Sources: tgui/packages/tgui/interfaces/AntagInfoMalf.tsx:55-120
Dynamic Asset Fetching
The Changelog system fetches localized .yml files based on dates. It uses js-yaml to parse content and maps specific change types to localized labels and icons.
Translation Schemas
The engine uses JSON schemas to define the structure of translation files. This ensures that all translation keys have corresponding values and meet the expected data types.
Schema Constraints
The schema.json file defines the requirements for translation entries:
- Key Mapping: Every English ID must map to a specific Russian string.
- Metadata: Translations include metadata for authorship and versioning.
- Changelog Categories: Standardized prefixes (e.g.,
bugfix,qol,soundadd) are used to categorize changes in both English and Russian changelogs.
Sources: modular_bandastation/translations/schema.json, html/changelogs/example.yml:10-30
Error Detection and Quality Control
The project uses shell scripts (check_grep.sh) to perform automated checks for common localization mistakes during CI (Continuous Integration).
Common Localization Errors
| Error Type | Detection Pattern | Target Files |
|---|---|---|
| Misspelling | nanotransen / NanoTrasen | Map and Code files |
| Misspelling | centcomm | Map and Code files |
| Typo | maintainance / securaty | Map and Code files |
| Encoding | CRLF line endings | Code files |
Sources: tools/ci/check_grep.sh:75-115, tools/ci/check_grep.sh:220-250
The engine enforces these rules to maintain high-quality text across the entire repository. If a developer uses improper casing or misspellings in strings, the CI suite flags these as errors and prevents merging. Sources: tools/ci/check_grep.sh:300-315
Conclusion
The Localization & Translation Engine is a multi-layered system combining Python validation scripts, JSON schemas for structural integrity, and React components for localized rendering. By enforcing strict naming rules and automated spelling checks, the system ensures a consistent experience for both Russian and English-speaking users. Sources: modular_bandastation/translations/validate_ru_names.py, tgui/packages/tgui/interfaces/ChangelogBandaStation.jsx