mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-25 14:05:57 +00:00
Map the zh-CN and zh-TW game languages to zh-Hans and zh-Hant
Choosing Simplified Chinese in the installer wrote lang = zh-CN to totk.ini and the game showed Japanese: ov_language() handed the code to nn::oe::GetDesiredLanguage unchanged, and TotK only accepts zh-Hans and zh-Hant for Chinese. Reported in #72 and #68. ov_language() now maps both old spellings, so existing totk.ini files keep working and cfg.c still accepts them. The F1 menu offers one row per language under the canonical codes. The installer lists only zh-Hans and zh-Hant, writes them, and reads zh-CN or zh-TW from the CLI or from a recorded totk-install.json as the canonical code, so a repair or update of an old install does not fail with check.lang_unknown and rewrites the ini. --probe-services prints the configured language and checks the four Chinese codes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
30c6c13161
commit
67116a387f
9 files changed
+37
-16
No files matched your search
+3
-2
@@ -266,8 +266,9 @@ class App:
|
||||
state = form.installed_state()
|
||||
if state is not None:
|
||||
self.update_hint.configure(text=self.cat('ui.update_mode'))
|
||||
if state.get('lang') in ini.LANGUAGES and not self.lang_touched:
|
||||
self.vars['lang'].set(self.lang_label(state['lang']))
|
||||
recorded = ini.canonical_language(state.get('lang'))
|
||||
if recorded in ini.LANGUAGES and not self.lang_touched:
|
||||
self.vars['lang'].set(self.lang_label(recorded))
|
||||
else:
|
||||
self.update_hint.configure(text='')
|
||||
self.fit()
|
||||
|
||||
+12
-4
@@ -9,19 +9,27 @@ import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
# runtime/ov_system.c: the codes TOTK_LANG accepts.
|
||||
# runtime/ov_system.c: the codes TOTK_LANG offers. Each language appears once, under the code the game accepts.
|
||||
LANGUAGES = ('ja', 'en-US', 'en-GB', 'fr', 'fr-CA', 'de', 'it', 'es', 'es-419', 'nl', 'pt', 'pt-BR', 'ru', 'ko',
|
||||
'zh-CN', 'zh-TW', 'zh-Hans', 'zh-Hant')
|
||||
'zh-Hans', 'zh-Hant')
|
||||
# Older installer builds wrote these two codes; they are read as the canonical ones and rewritten on the next install.
|
||||
ALIASES = {'zh-CN': 'zh-Hans', 'zh-TW': 'zh-Hant'}
|
||||
# Their text falls back to the Switch shared fonts (runtime/ov_system.c), which the installer does not extract.
|
||||
NEED_SHARED_FONTS = ('ko', 'zh-CN', 'zh-TW', 'zh-Hans', 'zh-Hant')
|
||||
NEED_SHARED_FONTS = ('ko', 'zh-Hans', 'zh-Hant')
|
||||
|
||||
ACTIVE = re.compile(r'^(\s*)(?:totk_)?lang(\s*=\s*)(.*?)(\s*)$', re.IGNORECASE)
|
||||
COMMENTED = re.compile(r'^\s*[#;]\s*(?:totk_)?lang\s*=.*$', re.IGNORECASE)
|
||||
SECTION = re.compile(r'^\s*\[(.*)\]\s*$')
|
||||
|
||||
|
||||
def canonical_language(lang):
|
||||
"""The code LANGUAGES lists for lang: an alias of an older installer build is mapped, anything else is kept."""
|
||||
return ALIASES.get(lang, lang)
|
||||
|
||||
|
||||
def set_language(text, lang):
|
||||
"""text with `lang = <lang>`; see the module docstring."""
|
||||
"""text with `lang = <lang>` (an alias written as its canonical code); see the module docstring."""
|
||||
lang = canonical_language(lang)
|
||||
lines = text.splitlines()
|
||||
for i, line in enumerate(lines):
|
||||
m = ACTIVE.match(line)
|
||||
|
||||
+1
-1
@@ -203,7 +203,7 @@ class Check(Step):
|
||||
raise InstallError('check.dest_not_folder', path=str(dest))
|
||||
if ctx.mode == 'install' and dest.is_dir() and any(dest.iterdir()):
|
||||
raise InstallError('check.dest_not_empty', path=str(dest))
|
||||
lang = ctx.options.lang or ctx.state.get('lang')
|
||||
lang = ini.canonical_language(ctx.options.lang or ctx.state.get('lang'))
|
||||
if not lang:
|
||||
raise InstallError('check.lang_missing')
|
||||
if lang not in ini.LANGUAGES:
|
||||
|
||||
@@ -166,8 +166,6 @@
|
||||
"lang.pt-BR": "Portuguese (Brazil)",
|
||||
"lang.ru": "Russian",
|
||||
"lang.ko": "Korean",
|
||||
"lang.zh-CN": "Chinese (Simplified, China)",
|
||||
"lang.zh-TW": "Chinese (Traditional, Taiwan)",
|
||||
"lang.zh-Hans": "Chinese (Simplified)",
|
||||
"lang.zh-Hant": "Chinese (Traditional)"
|
||||
}
|
||||
@@ -166,8 +166,6 @@
|
||||
"lang.pt-BR": "Португальский (Бразилия)",
|
||||
"lang.ru": "Русский",
|
||||
"lang.ko": "Корейский",
|
||||
"lang.zh-CN": "Китайский (упрощённый, КНР)",
|
||||
"lang.zh-TW": "Китайский (традиционный, Тайвань)",
|
||||
"lang.zh-Hans": "Китайский (упрощённый)",
|
||||
"lang.zh-Hant": "Китайский (традиционный)"
|
||||
}
|
||||
Reference in new issue
Block a user