Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Two independent layers share one selected language (`AppSettings.get_selected_la
1. **UI chrome** is translated via `src/utils/i18n.py`: `tr("dot.path.key", **kwargs)` reads `languages/{lang}/ui.json`, overlaid on English so missing keys fall back (then to the bare key). A runtime switch re-merges strings, and `MainWindow.retranslate_ui()` (with each tab's own `retranslate_ui`) sets the built widgets' texts again, the texts a refresh or a load writes included, so a switch shows what a restart in that language shows. `tests/test_language_switch_text.py` compares the two text by text, in both views with nothing loaded, and fails on a text there that has no `retranslate_ui` line (#540). Languages whose `ui.json` is a stub (only `_comment`) are hidden from the selector by `get_available_languages()`.
2. **Game strings**: English `base.ini` comes from local P4K extraction; every other language downloads a community `global.ini` per `languages/sources.json` (per-user URL override via the Config tab's *Map Language File* dialog). Caches are per-language: English at `{channel}\cache\base.ini`, others at `{channel}\cache\lang\{language}\base.ini` (`get_base_ini_path(language)`). The `global` merge source follows the selected language by one rule, `AppSettings.get_global_source_base_ini()` (the language's own base.ini when this channel has it, otherwise the English one), at startup, after a channel switch or a data-folder change and after a successful global.ini extraction (#502). The Blueprint Tracker's Owned set holds display names, so each load renames an owned name saved in another language to the loaded one through its loc key, read from one cached base.ini per other language (whichever channel has it), and a scan and Import Owned Blueprints do the same with their names (#569, see `src/gui/CLAUDE.md`).

Enhancements are language-aware: generated INIs live next to that language's `base.ini` (`get_enhancements_dir()`), and a `.dataforge_stamp` marker per language triggers regeneration on switch when stale (English included). A generation empties that stamp just before the generator's `main()` runs (a failure before that keeps the old one) and writes it when `main()` returns, so the startup check also offers to regenerate a set whose last run was cut off or failed. Generator annotation paths always parse the *English* base.ini, so stat blocks stay English by design; mixed values (e.g. `Role: Cannoniere`) are intentional. The apply side is language-aware too: `get_global_ini_path()` writes `Localization\{sc_id}\global.ini` and `ensure_user_cfg_language()` sets `g_language` to match, both via `SC_LANGUAGE_IDS` (app folder name `portuguese_br` → game id `portuguese_(brazil)`). Turkish borrows `polish_(poland)` and Russian borrows `korean_(south_korea)`, because the game accepts neither language's own id; Russian and Korean sharing one slot is the one deliberate exception to "a borrowed slot is never shared" (the Korean font is the only in-game font with Cyrillic), so applying either replaces the other's `global.ini`.
Enhancements are language-aware: generated INIs live next to that language's `base.ini` (`get_enhancements_dir()`), and a `.dataforge_stamp` marker per language triggers regeneration on switch when stale (English included). A generation empties that stamp just before the generator's `main()` runs (a failure before that keeps the old one) and writes it when `main()` returns, so the startup check also offers to regenerate a set whose last run was cut off or failed. Generator annotation paths always parse the *English* base.ini (tags and lookups stay English), while the text the generator adds itself (stat labels, mission details, journal lines) is translated through `languages/{lang}/enhancements.json` (#579, see `src/utils/CLAUDE.md` → `enhancement_text.py`); the mission section headers, the Rep label, tags such as `[BP]` and item names stay as they are. A translated language's `.dataforge_stamp` carries its table's fingerprint (`AppSettings.enhancements_stamp_value`), so an update that changes the table makes the set out of date. Each start also fetches the selected language's community global.ini again when its source is a URL (`MainWindow._check_language_translation_at_startup`, a conditional request) and, when a new file came down, empties that language's stamp and reloads as a language switch does, so a translation fixed after a game patch arrives without a switch. The apply side is language-aware too: `get_global_ini_path()` writes `Localization\{sc_id}\global.ini` and `ensure_user_cfg_language()` sets `g_language` to match, both via `SC_LANGUAGE_IDS` (app folder name `portuguese_br` → game id `portuguese_(brazil)`). Turkish borrows `polish_(poland)` and Russian borrows `korean_(south_korea)`, because the game accepts neither language's own id; Russian and Korean sharing one slot is the one deliberate exception to "a borrowed slot is never shared" (the Korean font is the only in-game font with Cyrillic), so applying either replaces the other's `global.ini`.

`languages/` must be bundled in **both** build lists (`SmartCitizen.spec` and `scripts/build/build_exe.py`), or the frozen app shows raw `tr()` keys.

Expand Down Expand Up @@ -213,7 +213,8 @@ Anchor examples already in-tree: `COL_*` constants in `src/gui/string_table_mode
| Move the DataForge cache off the default path | `src/utils/settings.py`, `src/gui/config_tab.py` | `AppSettings.get_cache_dir_override()` / `set_cache_dir()` (1.4.1+; independent of the user-data override); `ConfigTab._maybe_apply_cache_change()` (undoes a change whose cache folder cannot be made, as Cancel does, and `_report_cache_folder_error()` says why in one box, #494) |
| Add or fix a translated UI string | `languages/{language}/ui.json`, `src/utils/i18n.py` | `tr()`, `set_language()` (dot-path keys; English is the fallback base) |
| Change the language-switch flow | `src/gui/config_tab.py`, `src/gui/main_window.py` | `language_changed` signal, `MainWindow._on_language_changed()` (retranslate chrome, repoint the `global` source, download base.ini when a URL is mapped, regen stale enhancements, reload) |
| Change per-language base.ini download / URL mapping | `src/gui/workers.py`, `src/utils/settings.py`, `languages/sources.json` | `LanguageBaseDownloadWorker`, `get_language_base_url()`, `LanguageSourceDialog` (Config tab's *Map Language File*) |
| Translate the text the generator adds (stat labels, mission details, journal lines) | `scripts/generate_enhancements_ini.py`, `src/utils/enhancement_text.py`, `languages/{language}/enhancements.json` | `_t()` (keyed by the English text), `load_table()`, `table_fingerprint()`; after adding a `_t()` text run `python tests/test_enhancement_text.py --write` and add it to every language's table (#579) |
| Change per-language base.ini download / URL mapping | `src/gui/workers.py`, `src/utils/settings.py`, `languages/sources.json` | `LanguageBaseDownloadWorker`, `get_language_base_url()`, `LanguageSourceDialog` (Config tab's *Map Language File*), `MainWindow._check_language_translation_at_startup()` / `_on_language_translation_checked()` (the start-time re-download, #579) |
| Change per-language cache or enhancements layout | `src/utils/settings.py` | `get_base_ini_path(language)` (and `get_base_ini_leaf(language, channel)`, the same file for any channel with no folder made, #564), `get_enhancements_dir(language)`, `get_/set_enhancements_stamp()` (the setters' `folder=` takes the folder a generation started with), `invalidate_enhancements_stamp()` |
| Toggle mission-detail fields per user | `src/gui/enhancements_tab.py`, `src/utils/settings.py` | `_MISSION_FIELD_SETTING` (per-field show/hide for mission bodies, #121); the `route` key adds the haul route to titles (#166) |
| Change hauling/delivery route-in-title | `scripts/generate_enhancements_ini.py` | `_derive_route_fragment()` / `_route_token_role()` / `_title_route_token()` / `_expand_nested_route_vars()` (#166, reworked in #200: |Address default, comma-listed endpoints, one-level `*Token` expansion, per-body intersection; applied in both the contractgen title loop and the pu-only second pass; placed before the [BP]/XP tags via the mission_titles TagConfig) |
Expand Down
3 changes: 2 additions & 1 deletion docs/HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ Pick a language from the **Language** dropdown in the **Config** tab (next to Ch

- **English** (the default) uses the stock strings extracted from your own `Data.p4k`.
- **Other languages** download that language's community-translated `global.ini` and layer it over the English base, so any string the translation doesn't cover falls back to English instead of going missing. The download is cached per language; switching back later reuses the cache.
- **Enhancements stay in English.** Stat blocks, tags, and mission details are generated from game data and keep their English form on top of the translated prose. A mixed line (say, a French role name inside an English stat block) is expected, not a bug.
- **Enhancements follow your language.** The stat labels, mission details and journal lines Smart Citizen adds are written in the language you picked. Item names come from the translation itself, and tags such as `[BP]` and the mission section headers stay as they are.
- **The translation stays up to date.** Each time Smart Citizen starts, it checks for a newer version of the community translation and reloads with it, so a fix made after a game patch reaches you without switching language.
- **Map Language File** (Config tab) lets you point a language at a different `global.ini` — a URL (for example your own fork of a community translation) or, via **Browse...**, a file you already have on disk. A URL is downloaded and cached; a local file is copied in. Either way it wins over the bundled default. For a language whose community translation can't be redistributed (e.g. Korean), local-file mapping is the only option — install that community's own patch first, **copy its `global.ini` somewhere other than your Star Citizen install** (mapping the copy Smart Citizen already applies there would feed its own merged output back in as the next "source" and double every enhancement), then Browse to that copy.
- **Russian and Korean share one game language slot.** The game has no Russian slot, and its Korean font is the only one that draws Cyrillic, so Russian is applied as the game's Korean language. Applying one replaces the other's file in the game, and only the one you applied last shows in-game.
- Some interface text updates only after an app restart. The table strings reload immediately.
Expand Down
4 changes: 4 additions & 0 deletions languages/TRANSLATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1135,3 +1135,7 @@ them against the new source.
one overwrites the other's `global.ini` in that folder. A Russian-speaking
reviewer replacing the `at` strings with `ht` is the next step to promote
it from AI-only to human-reviewed.

## Generated text (`enhancements.json`, #579)

The text Smart Citizen adds to the game strings (stat labels such as `Max HP`, mission details, journal lines) is translated in `languages/<lang>/enhancements.json`, beside `ui.json`. Its keys are the English texts, listed in `languages/english/enhancements.json`, and each leaf has the same `ht` / `at` fields with the same rules: `ht` wins, then `at`, and an empty leaf stays English. Keep every `{placeholder}` and `<EM4>`-style tag. Every non-English table was first written as AI drafts (`at`, with `ht` empty), so all of it is open for review. Item names, tags such as `[BP]`, the mission section headers and the Rep label are not in this file: names come from the community translation, and the headers and the label are settings on the Enhancements tab.
3 changes: 2 additions & 1 deletion languages/chinese/HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@

- **英语**(默认)使用从你自己的 `Data.p4k` 中提取的官方字符串。
- **其他语言** 会下载该语言社区翻译的 `global.ini`,并将其叠加在英文基础内容之上,因此任何翻译未覆盖的字符串会回退到英文而不是缺失。下载内容按语言缓存;之后切换回来会复用缓存。
- **增强内容始终保持英文。** 数据统计块、标签和任务详情是根据游戏数据生成的,会在翻译后的文本之上保留其英文形式。混合行(例如英文数据统计块中出现的法语阵营名称)是预期行为,而非 Bug。
- **增强内容跟随你的语言。** Smart Citizen 添加的属性标签、任务详情和日志条目会以你选择的语言显示。物品名称来自翻译本身,`[BP]` 等标签和任务的章节标题保持不变。
- **翻译会保持最新。** 每次启动时,Smart Citizen 都会检查社区翻译是否有更新版本,如有则用它重新加载。因此游戏补丁后的修正无需切换语言即可送达。
- **映射语言文件**(配置标签页)可让你将某种语言指向另一个 `global.ini`:可以是一个地址(例如你自己分支的社区翻译),也可以通过 **浏览…** 选择磁盘上已有的文件。地址会被下载并缓存,本地文件会被复制进来。无论哪种方式,都优先于内置默认值。对于社区翻译不能再分发的语言(例如韩语),映射本地文件是唯一的选择:先安装该社区自己的补丁,**把它的 `global.ini` 复制到《星际公民》安装目录之外的位置**(如果映射 Smart Citizen 已在那里应用的副本,会把它自己合并后的输出当作下一个“来源”再读进来,使每项增强内容翻倍),然后用浏览选择该副本。
- **俄语和韩语共用游戏的同一个语言槽位。** 游戏没有俄语槽位,而只有韩语字体能显示西里尔字母,因此俄语会作为游戏的韩语来应用。应用其中一种会替换游戏中另一种的文件,游戏内只显示最后应用的那一种。
- 部分界面文本仅在应用重启后才会更新。表格字符串会立即重新加载。
Expand Down
Loading
Loading