mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-21 12:55: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
-1
@@ -250,8 +250,10 @@ static void probe_oe(void) {
|
||||
{NULL, "en-US", "en-US"}, {NULL, "be-BY", "en-US"}, {NULL, "xx", "en-US"}, {NULL, "ja-JP", "ja"},
|
||||
{NULL, "fr-CA", "fr-CA"}, {NULL, "es-MX", "es-419"}, {NULL, "es_ES", "es"}, {NULL, "zh-Hant-TW", "zh-Hant"},
|
||||
{NULL, "zh-CN", "zh-Hans"}, {NULL, "en-GB", "en-GB"}, {NULL, "ru", "ru"}, {"ja", "fr-FR", "ja"},
|
||||
{"en-US", NULL, "en-US"}};
|
||||
{"en-US", NULL, "en-US"}, {"zh-CN", NULL, "zh-Hans"}, {"zh-TW", NULL, "zh-Hant"},
|
||||
{"zh-Hans", NULL, "zh-Hans"}, {"zh-Hant", NULL, "zh-Hant"}};
|
||||
int bad = 0;
|
||||
printf("oe: configured language (TOTK_LANG=%s) is %s\n", keep_lang ? keep_lang : "", lang());
|
||||
for (size_t i = 0; i < sizeof cases / sizeof *cases; i++) {
|
||||
set_env("TOTK_LANG", cases[i].lang);
|
||||
set_env("TOTK_LOCALE", cases[i].locale);
|
||||
|
||||
+7
-3
@@ -88,12 +88,16 @@ static const char *switch_language(const char *tag) {
|
||||
return "en-US";
|
||||
}
|
||||
|
||||
// The game's language as a Switch language code (TOTK_LANG, else TOTK_LOCALE, else the Windows user locale).
|
||||
// The game's language as a Switch language code (TOTK_LANG, else TOTK_LOCALE, else the Windows user locale). TotK
|
||||
// accepts "zh-Hans" and "zh-Hant" for Chinese and falls back to Japanese for "zh-CN" and "zh-TW", so those two
|
||||
// spellings, which older totk.ini files and menus wrote, are mapped to them.
|
||||
const char *ov_language(void) {
|
||||
static const char *const codes[] = {"ja", "en-US", "fr", "de", "it", "es", "zh-CN", "ko", "nl", "pt", "ru",
|
||||
"zh-TW", "en-GB", "fr-CA", "es-419", "zh-Hans", "zh-Hant", "pt-BR"};
|
||||
static const char *const codes[] = {"ja", "en-US", "fr", "de", "it", "es", "ko", "nl", "pt", "ru",
|
||||
"en-GB", "fr-CA", "es-419", "zh-Hans", "zh-Hant", "pt-BR"};
|
||||
const char *code = cfg_get("TOTK_LANG"); // no fixed default: TOTK_LOCALE or the Windows user locale decides when unset
|
||||
if (code && *code) {
|
||||
if (!strcmp(code, "zh-CN")) return "zh-Hans";
|
||||
if (!strcmp(code, "zh-TW")) return "zh-Hant";
|
||||
for (size_t i = 0; i < sizeof codes / sizeof *codes; i++)
|
||||
if (!strcmp(code, codes[i])) return codes[i];
|
||||
rt_fatal("TOTK_LANG '%s' is not a Switch language code", code);
|
||||
|
||||
+1
-1
@@ -458,7 +458,7 @@ static void row_game_lang(void) {
|
||||
{"en-US", UI_MENU_LANGNAME_EN}, {"ja", UI_MENU_LANGNAME_JA}, {"fr", UI_MENU_LANGNAME_FR},
|
||||
{"de", UI_MENU_LANGNAME_DE}, {"it", UI_MENU_LANGNAME_IT}, {"es", UI_MENU_LANGNAME_ES},
|
||||
{"nl", UI_MENU_LANGNAME_NL}, {"ru", UI_MENU_LANGNAME_RU},
|
||||
{"zh-CN", UI_MENU_LANGNAME_ZH_HANS}, {"zh-TW", UI_MENU_LANGNAME_ZH_HANT}, {"ko", UI_MENU_LANGNAME_KO},
|
||||
{"zh-Hans", UI_MENU_LANGNAME_ZH_HANS}, {"zh-Hant", UI_MENU_LANGNAME_ZH_HANT}, {"ko", UI_MENU_LANGNAME_KO},
|
||||
};
|
||||
enum { N = sizeof langs / sizeof *langs + 1 };
|
||||
const char *vals[N], *names[N];
|
||||
|
||||
Reference in new issue
Block a user