From fbd624a02e165a6edff0f740532cbc948b5c0f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Fri, 18 Sep 2026 05:16:25 +0200 Subject: [PATCH] [Card] Show card languages in the same native (English) format as the UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address review: the card text & images language dropdown listed bare native names, some in inconsistent lowercase (e.g. "čeština", "español de España"), which makes the languages easy to mix up for users that do not read the script (e.g. 日本語 vs 한국어). It now mirrors the UI language dropdown and always pairs the native name with its English name (e.g. "Deutsch (German)", "日本語 (Japanese)"), using the same fixed casing. --- .../libcockatrice/card/card_localization.cpp | 23 +++++++++++++++---- .../libcockatrice/card/card_localization.h | 9 +++++--- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/libcockatrice_card/libcockatrice/card/card_localization.cpp b/libcockatrice_card/libcockatrice/card/card_localization.cpp index b5cdd1d7a..03c6c659b 100644 --- a/libcockatrice_card/libcockatrice/card/card_localization.cpp +++ b/libcockatrice_card/libcockatrice/card/card_localization.cpp @@ -1,5 +1,6 @@ #include "card_localization.h" +#include #include #include @@ -13,11 +14,23 @@ const QStringList &supportedLanguages() QString languageDisplayName(const QString &lang) { - if (lang == "zhs") { - return QStringLiteral("简体中文"); - } - if (lang == "zht") { - return QStringLiteral("繁體中文"); + static const QHash displayNames = { + {"cs", "Česky (Czech)"}, + {"de", "Deutsch (German)"}, + {"es", "Español (Spanish)"}, + {"fr", "Français (French)"}, + {"it", "Italiano (Italian)"}, + {"ja", "日本語 (Japanese)"}, + {"ko", "한국어 (Korean)"}, + {"pt", "Português (Portuguese)"}, + {"ru", "Русский (Russian)"}, + {"he", "עברית (Hebrew)"}, + {"zhs", "简体中文 (Chinese Simplified)"}, + {"zht", "繁體中文 (Chinese Traditional)"}, + }; + const QString displayName = displayNames.value(lang); + if (!displayName.isEmpty()) { + return displayName; } const QString nativeName = QLocale(lang).nativeLanguageName(); return nativeName.isEmpty() ? lang : nativeName; diff --git a/libcockatrice_card/libcockatrice/card/card_localization.h b/libcockatrice_card/libcockatrice/card/card_localization.h index 3493718af..a9c8d28ea 100644 --- a/libcockatrice_card/libcockatrice/card/card_localization.h +++ b/libcockatrice_card/libcockatrice/card/card_localization.h @@ -28,11 +28,14 @@ namespace CardLocalization [[nodiscard]] const QStringList &supportedLanguages(); /** - * @brief Human-readable native name for a language code. + * @brief Human-readable name for a language code. + * + * Follows the same "native name (English name)" format the UI language list + * uses (e.g. "日本語 (Japanese)"), so the English fallback is always visible. * * @param lang Language code (e.g. "de", "ja", "zhs"). - * @return The language's name in its own language, or the code itself if - * it cannot be resolved. + * @return The language's native name with its English name in parentheses, or + * the code itself if it cannot be resolved. */ [[nodiscard]] QString languageDisplayName(const QString &lang); } // namespace CardLocalization