mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-22 01:25:10 -07:00
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.
38 lines
No EOL
1.2 KiB
C++
38 lines
No EOL
1.2 KiB
C++
#include "card_localization.h"
|
|
|
|
#include <QHash>
|
|
#include <QLocale>
|
|
#include <QStringList>
|
|
|
|
namespace CardLocalization
|
|
{
|
|
const QStringList &supportedLanguages()
|
|
{
|
|
static const QStringList languages = {"cs", "de", "es", "fr", "it", "ja", "ko", "pt", "ru", "zhs", "zht", "he"};
|
|
return languages;
|
|
}
|
|
|
|
QString languageDisplayName(const QString &lang)
|
|
{
|
|
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;
|
|
}
|
|
} // namespace CardLocalization
|