From cd7cb1cc11fdcae484fc6b2d447be96e045fed1b Mon Sep 17 00:00:00 2001 From: Arsh Kumar Singh Date: Sun, 10 May 2026 20:55:00 +0530 Subject: [PATCH] Qt: include territory in language menu labels (#18704) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Fixes the GUI language dropdown to show territory variants when translation files include country codes. **Before:** "Portuguese" for both `pt_BR` and `pt_PT` **After:** "Portuguese (Brazil)" and "Portuguese (Portugal)" Also fixes the same ambiguity for Chinese and any other language with country variants. ## Implementation Uses `QLocale::territoryToString()` alongside the existing `QLocale::languageToString()` to construct display labels. When no territory exists (e.g., `en`, `ja`), the label is unchanged. ## Edge cases - No-territory locales (`en`, `ja`): unchanged — `QLocale::territoryToString(AnyTerritory)` returns empty, guard preserves plain language name - Territory names are locale-translated (not hardcoded English) — they follow the current UI language, same as `languageToString()` - `zh_CN` → "Chinese (China)" / `zh_TW` → "Chinese (Taiwan)" (territory-based, unlike the PS3 system language dropdown which uses Simplified/Traditional script names — this is appropriate for the GUI translator selector context) ## Test Plan - [ ] Language menu shows "Portuguese (Brazil)" when `rpcs3_pt_BR.qm` is present - [ ] Language menu shows "Chinese (China)" when `rpcs3_zh_CN.qm` is present - [ ] Plain languages (`en`, `ja`) continue to show without parens ---
Review note: territory strings in UI locale Territory names render in the current UI language (not forced English). This matches `QLocale::languageToString()` behavior and is consistent with how the rest of the menu renders. If hardcoded English labels are preferred, that can be added after review.
Fixes #18215 --- rpcs3/rpcs3qt/main_window.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 97081aca4a..28f76a63bc 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -2298,11 +2298,19 @@ void main_window::UpdateLanguageActions(const QStringList& language_codes, const { const QLocale locale = QLocale(code); const QString locale_name = QLocale::languageToString(locale.language()); + const QString territory = QLocale::territoryToString(locale.territory()); + + const bool is_unique = std::count_if(language_codes.cbegin(), language_codes.cend(), [&locale_name](const QString& code) + { + return locale_name == QLocale::languageToString(QLocale(code).language()); + }) == 1; + + const QString display_name = (!is_unique && !territory.isEmpty()) ? QString("%1 (%2)").arg(locale_name, territory) : locale_name; // create new action - QAction* act = new QAction(locale_name, this); + QAction* act = new QAction(display_name, this); act->setData(code); - act->setToolTip(locale_name); + act->setToolTip(display_name); act->setCheckable(true); act->setChecked(code == language_code);