mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[Card] Show card languages in the same native (English) format as the UI
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.
This commit is contained in:
parent
fa89662172
commit
fbd624a02e
2 changed files with 24 additions and 8 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "card_localization.h"
|
||||
|
||||
#include <QHash>
|
||||
#include <QLocale>
|
||||
#include <QStringList>
|
||||
|
||||
|
|
@ -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<QString, QString> 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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue