2023-02-09 22:26:25 +02:00
|
|
|
/*
|
|
|
|
* Languages.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Languages
|
|
|
|
{
|
|
|
|
|
|
|
|
enum class ELanguages
|
|
|
|
{
|
2023-03-06 18:39:32 +02:00
|
|
|
CHINESE,
|
2023-02-09 22:26:25 +02:00
|
|
|
ENGLISH,
|
|
|
|
FRENCH,
|
|
|
|
GERMAN,
|
2023-03-12 23:33:38 +02:00
|
|
|
KOREAN, // currently has no translations or detection
|
2023-02-09 22:26:25 +02:00
|
|
|
POLISH,
|
|
|
|
RUSSIAN,
|
2023-03-12 23:33:38 +02:00
|
|
|
SPANISH,
|
2023-02-09 22:26:25 +02:00
|
|
|
UKRAINIAN,
|
|
|
|
|
2023-03-08 00:23:37 +02:00
|
|
|
// Pseudo-languages, that have no translations but can define H3 encoding to use
|
|
|
|
OTHER_CP1250,
|
|
|
|
OTHER_CP1251,
|
|
|
|
OTHER_CP1252,
|
|
|
|
|
2023-02-09 22:26:25 +02:00
|
|
|
COUNT
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Options
|
|
|
|
{
|
|
|
|
/// string identifier (ascii, lower-case), e.g. "english"
|
|
|
|
std::string identifier;
|
|
|
|
|
|
|
|
/// human-readable name of language in English
|
|
|
|
std::string nameEnglish;
|
|
|
|
|
|
|
|
/// human-readable name of language in its own language
|
|
|
|
std::string nameNative;
|
|
|
|
|
|
|
|
/// encoding that is used by H3 for this language
|
|
|
|
std::string encoding;
|
|
|
|
|
|
|
|
/// VCMI is capable of detecting H3 install in this language
|
|
|
|
bool hasDetection = false;
|
|
|
|
|
|
|
|
/// VCMI supports translations into this language
|
|
|
|
bool hasTranslation = false;
|
|
|
|
};
|
|
|
|
|
2023-03-08 00:23:37 +02:00
|
|
|
inline const auto & getLanguageList()
|
2023-02-09 22:26:25 +02:00
|
|
|
{
|
2023-03-12 23:33:38 +02:00
|
|
|
static const std::array<Options, 12> languages
|
2023-02-09 22:26:25 +02:00
|
|
|
{ {
|
2023-03-12 23:33:38 +02:00
|
|
|
{ "chinese", "Chinese", "简体中文", "GBK", true, true }, // Note: actually Simplified Chinese
|
2023-02-09 22:26:25 +02:00
|
|
|
{ "english", "English", "English", "CP1252", true, true },
|
2023-03-06 18:39:32 +02:00
|
|
|
{ "french", "French", "Français", "CP1252", true, true },
|
2023-02-09 22:26:25 +02:00
|
|
|
{ "german", "German", "Deutsch", "CP1252", true, true },
|
2023-03-12 23:33:38 +02:00
|
|
|
{ "korean", "Korean", "한국어", "CP949", false, false },
|
2023-02-09 22:26:25 +02:00
|
|
|
{ "polish", "Polish", "Polski", "CP1250", true, true },
|
|
|
|
{ "russian", "Russian", "Русский", "CP1251", true, true },
|
2023-03-12 23:33:38 +02:00
|
|
|
{ "spanish", "Spanish", "Español", "CP1252", false, true },
|
2023-03-08 00:23:37 +02:00
|
|
|
{ "ukrainian", "Ukrainian", "Українська", "CP1251", true, true },
|
|
|
|
|
|
|
|
{ "other_cp1250", "Other (East European)", "", "CP1251", false, false },
|
|
|
|
{ "other_cp1251", "Other (Cyrillic Script)", "", "CP1250", false, false },
|
2023-03-08 02:01:56 +02:00
|
|
|
{ "other_cp1252", "Other (West European)", "", "CP1252", false, false }
|
2023-02-09 22:26:25 +02:00
|
|
|
} };
|
2023-03-08 00:23:37 +02:00
|
|
|
static_assert(languages.size() == static_cast<size_t>(ELanguages::COUNT), "Languages array is missing a value!");
|
2023-02-09 22:26:25 +02:00
|
|
|
|
|
|
|
return languages;
|
|
|
|
}
|
|
|
|
|
2023-03-08 00:23:37 +02:00
|
|
|
inline const Options & getLanguageOptions(ELanguages language)
|
2023-02-09 22:26:25 +02:00
|
|
|
{
|
|
|
|
assert(language < ELanguages::COUNT);
|
|
|
|
return getLanguageList()[static_cast<size_t>(language)];
|
|
|
|
}
|
|
|
|
|
2023-03-08 00:23:37 +02:00
|
|
|
inline const Options & getLanguageOptions(const std::string & language)
|
2023-02-09 22:26:25 +02:00
|
|
|
{
|
2023-03-08 00:23:37 +02:00
|
|
|
for(const auto & entry : getLanguageList())
|
|
|
|
if(entry.identifier == language)
|
2023-02-09 22:26:25 +02:00
|
|
|
return entry;
|
|
|
|
|
|
|
|
static const Options emptyValue;
|
|
|
|
assert(0);
|
|
|
|
return emptyValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|