diff --git a/runtime/ov_probe.c b/runtime/ov_probe.c index c7ff374d..89fbecb1 100644 --- a/runtime/ov_probe.c +++ b/runtime/ov_probe.c @@ -889,10 +889,26 @@ static void probe_menu_text(void) { CHECK(!strcmp(ui_text_in("ru", UI_SWKBD_OK), "ОК") && !strcmp(ui_text_in("de", UI_SWKBD_CANCEL), "Abbrechen") && !strcmp(ui_text_in("en", UI_SWKBD_OK), "OK"), "keyboard texts changed"); // language names: the same string in every row - for (int id = UI_MENU_LANGNAME_EN; id <= UI_MENU_LANGNAME_PT_BR; id++) + for (int id = UI_MENU_LANGNAME_EN; id <= UI_MENU_LANGNAME_ES_419; id++) for (size_t i = 1; i < sizeof langs / sizeof *langs; i++) CHECK(!strcmp(ui_text_in(langs[i], (UiTextId)id), ui_text_in("en", (UiTextId)id)), "language name %d differs in %s", id, langs[i]); CHECK(!strcmp(ui_text_in("en", UI_MENU_LANGNAME_RU), "Русский"), "Russian is not shown as Russian"); + // game language list: pt-BR only where the build ships USpt; the Switch variants are entries of their own + { + UiGameLang gl[16]; + int n121 = ui_text_game_langs(121, gl, 16), has[16] = {0}; + for (int i = 0; i < n121; i++) CHECK(strcmp(gl[i].code, "pt-BR"), "1.2.1 game language list offers pt-BR"); + int n143 = ui_text_game_langs(143, gl, 16), pt = 0; + for (int i = 0; i < n143; i++) { + pt |= !strcmp(gl[i].code, "pt-BR"); + for (int j = 0; j < i; j++) CHECK(strcmp(gl[i].code, gl[j].code), "duplicate game language %s", gl[i].code); + } + CHECK(pt && n143 == n121 + 1, "1.4.3 game language list lacks pt-BR"); + static const char *const want[] = {"en-GB", "fr-CA", "es-419"}; + for (int w = 0; w < 3; w++) + for (int i = 0; i < n143; i++) has[w] |= !strcmp(gl[i].code, want[w]); + CHECK(has[0] && has[1] && has[2], "game language list lacks en-GB, fr-CA or es-419"); + } // the overlay formats keep their conversions CHECK(strstr(ui_text_in("ru", UI_MENU_OV_GAME_PCT), "%.0f%%") && strstr(ui_text_in("ru", UI_MENU_OV_MAX_MS), "%.1f"), "overlay format lost its conversion"); diff --git a/runtime/ui/menu.cpp b/runtime/ui/menu.cpp index b1777f22..8f4a15f0 100644 --- a/runtime/ui/menu.cpp +++ b/runtime/ui/menu.cpp @@ -559,27 +559,25 @@ static void row_gpu(void) { opt_choice_list("TOTK_GPU_INDEX", UI_MENU_GPU, vals, names, g_gpu_n + 1, UI_MENU_GPU_DESC); } -// The game language: one entry per language TotK ships (a Switch code that names it), each under its own name. The -// Switch's Portuguese is not among them. +// The game language: one entry per Mals language file the running game build ships (ui_text_game_langs), each under +// its own name. A code that names no entry exactly (older "en", "fr-CA" on a build without it) selects the first entry +// of the same catalog language. static void row_game_lang(void) { - static const struct { const char *code; UiTextId name; } langs[] = { - {"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-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]; + UiGameLang langs[16]; + int n = ui_text_game_langs(rt_game_version, langs, 16); + const char *vals[17], *names[17]; vals[0] = ""; names[0] = menu_text(UI_MENU_GAME_LANG_AUTO); const char *now = cfg_value("TOTK_LANG"); int cur = *now ? -1 : 0; - for (int i = 1; i < N; i++) { + for (int i = 1; i <= n; i++) { vals[i] = langs[i - 1].code; names[i] = menu_text(langs[i - 1].name); - if (*now && !strcmp(ui_text_lang(now), ui_text_lang(vals[i]))) cur = i; // en-GB is English too + if (*now && !strcmp(now, vals[i])) cur = i; } - opt_choice_list("TOTK_LANG", UI_MENU_GAME_LANG, vals, names, N, UI_MENU_GAME_LANG_DESC, cur); + for (int i = 1; i <= n && *now && cur < 0; i++) + if (!strcmp(ui_text_lang(now), ui_text_lang(vals[i]))) cur = i; + opt_choice_list("TOTK_LANG", UI_MENU_GAME_LANG, vals, names, n + 1, UI_MENU_GAME_LANG_DESC, cur); } // The frame limit (frame_rate.c): unset, the older fps60 = 0 still means 30. The monitor choice shows the rate it gives. diff --git a/runtime/ui_text.c b/runtime/ui_text.c index d023b66a..293d3c38 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -18,7 +18,8 @@ typedef struct { const char *lang; const char *const *text; } Row; [UI_MENU_LANGNAME_DE] = "Deutsch", [UI_MENU_LANGNAME_IT] = "Italiano", [UI_MENU_LANGNAME_ES] = "Español", \ [UI_MENU_LANGNAME_NL] = "Nederlands", [UI_MENU_LANGNAME_RU] = "Русский", \ [UI_MENU_LANGNAME_ZH_HANS] = "简体中文", [UI_MENU_LANGNAME_ZH_HANT] = "繁體中文", [UI_MENU_LANGNAME_KO] = "한국어", \ - [UI_MENU_LANGNAME_PT_BR] = "Português (Brasil)" + [UI_MENU_LANGNAME_PT_BR] = "Português (Brasil)", [UI_MENU_LANGNAME_EN_GB] = "English (UK)", \ + [UI_MENU_LANGNAME_FR_CA] = "Français (Canada)", [UI_MENU_LANGNAME_ES_419] = "Español (Latinoamérica)" // SWKBD: TITLE, PROMPT, DEFAULT_NAME (at most 9 UTF-16 units, no '@' '%' '\'), OK, CANCEL, PAD_HINT. #define SWKBD(title, prompt, name, ok, cancel, hint) \ @@ -1932,6 +1933,22 @@ const char *ui_text_lang(const char *code) { return code; } +// Every game language: the Mals files EUen/USen, USfr/EUfr, USes/EUes ship in both builds; USpt only from 1.4.3. +int ui_text_game_langs(int game_version, UiGameLang *out, int max) { + static const struct { const char *code; UiTextId name; int since; } all[] = { + {"en-US", UI_MENU_LANGNAME_EN, 0}, {"en-GB", UI_MENU_LANGNAME_EN_GB, 0}, {"ja", UI_MENU_LANGNAME_JA, 0}, + {"fr", UI_MENU_LANGNAME_FR, 0}, {"fr-CA", UI_MENU_LANGNAME_FR_CA, 0}, {"de", UI_MENU_LANGNAME_DE, 0}, + {"it", UI_MENU_LANGNAME_IT, 0}, {"es", UI_MENU_LANGNAME_ES, 0}, {"es-419", UI_MENU_LANGNAME_ES_419, 0}, + {"pt-BR", UI_MENU_LANGNAME_PT_BR, 143}, {"nl", UI_MENU_LANGNAME_NL, 0}, {"ru", UI_MENU_LANGNAME_RU, 0}, + {"zh-Hans", UI_MENU_LANGNAME_ZH_HANS, 0}, {"zh-Hant", UI_MENU_LANGNAME_ZH_HANT, 0}, + {"ko", UI_MENU_LANGNAME_KO, 0}, + }; + int n = 0; + for (size_t i = 0; i < sizeof all / sizeof *all && n < max; i++) + if (game_version >= all[i].since) out[n++] = (UiGameLang){all[i].code, all[i].name}; + return n; +} + static const Row *find_row(const char *lang) { for (size_t i = 0; i < sizeof rows / sizeof *rows; i++) if (!strcmp(rows[i].lang, lang)) return &rows[i]; diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 1845d052..116128c1 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -154,7 +154,8 @@ typedef enum { // Language names, each in its own language and the same in every row (game language and menu language lists) UI_MENU_LANGNAME_EN, UI_MENU_LANGNAME_JA, UI_MENU_LANGNAME_FR, UI_MENU_LANGNAME_DE, UI_MENU_LANGNAME_IT, UI_MENU_LANGNAME_ES, UI_MENU_LANGNAME_NL, UI_MENU_LANGNAME_RU, UI_MENU_LANGNAME_ZH_HANS, - UI_MENU_LANGNAME_ZH_HANT, UI_MENU_LANGNAME_KO, UI_MENU_LANGNAME_PT_BR, + UI_MENU_LANGNAME_ZH_HANT, UI_MENU_LANGNAME_KO, UI_MENU_LANGNAME_PT_BR, UI_MENU_LANGNAME_EN_GB, + UI_MENU_LANGNAME_FR_CA, UI_MENU_LANGNAME_ES_419, // Advanced UI_MENU_ADV_WARNING, @@ -246,6 +247,12 @@ int ui_text_defined(const char *lang, UiTextId id); // The catalog language for a Switch language code ("en-GB" -> "en", "zh-CN" -> "zh-Hans", ...). const char *ui_text_lang(const char *switch_code); +// The game languages the F1 menu offers for a game build (rt_game_version): one entry per Mals language file the build +// ships, each with the Switch code TOTK_LANG takes and the id of its name. 1.4.3 adds Brazilian Portuguese (USpt). +// Fills out (room for max entries) and returns the count. +typedef struct { const char *code; UiTextId name; } UiGameLang; +int ui_text_game_langs(int game_version, UiGameLang *out, int max); + // Menu text: ui_text_in(menu language, id). The menu language is TOTK_MENU_LANG ("en", "ru", "pt-BR", "zh-Hans"); // unset, the system UI language when the catalog has menu text for it (English, Russian, Brazilian Portuguese, // Simplified Chinese), else English. Follows a live change of the setting.