Languages.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Languages.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. namespace Languages
  12. {
  13. enum class ELanguages
  14. {
  15. CZECH,
  16. CHINESE,
  17. ENGLISH,
  18. FINNISH,
  19. FRENCH,
  20. GERMAN,
  21. HUNGARIAN,
  22. ITALIAN,
  23. KOREAN,
  24. POLISH,
  25. PORTUGUESE,
  26. RUSSIAN,
  27. SPANISH,
  28. SWEDISH,
  29. TURKISH,
  30. UKRAINIAN,
  31. // Pseudo-languages, that have no translations but can define H3 encoding to use
  32. OTHER_CP1250,
  33. OTHER_CP1251,
  34. OTHER_CP1252,
  35. COUNT
  36. };
  37. struct Options
  38. {
  39. /// string identifier (ascii, lower-case), e.g. "english"
  40. std::string identifier;
  41. /// human-readable name of language in English
  42. std::string nameEnglish;
  43. /// human-readable name of language in its own language
  44. std::string nameNative;
  45. /// encoding that is used by H3 for this language
  46. std::string encoding;
  47. /// primary IETF language tag
  48. std::string tagIETF;
  49. /// VCMI supports translations into this language
  50. bool hasTranslation = false;
  51. };
  52. inline const auto & getLanguageList()
  53. {
  54. static const std::array<Options, 19> languages
  55. { {
  56. { "czech", "Czech", "Čeština", "CP1250", "cs", true },
  57. { "chinese", "Chinese", "简体中文", "GBK", "zh", true }, // Note: actually Simplified Chinese
  58. { "english", "English", "English", "CP1252", "en", true },
  59. { "finnish", "Finnish", "Suomi", "CP1252", "fi", true },
  60. { "french", "French", "Français", "CP1252", "fr", true },
  61. { "german", "German", "Deutsch", "CP1252", "de", true },
  62. { "hungarian", "Hungarian", "Magyar", "CP1250", "hu", true },
  63. { "italian", "Italian", "Italiano", "CP1250", "it", true },
  64. { "korean", "Korean", "한국어", "CP949", "ko", true },
  65. { "polish", "Polish", "Polski", "CP1250", "pl", true },
  66. { "portuguese", "Portuguese", "Português", "CP1252", "pt", true }, // Note: actually Brazilian Portuguese
  67. { "russian", "Russian", "Русский", "CP1251", "ru", true },
  68. { "spanish", "Spanish", "Español", "CP1252", "es", true },
  69. { "swedish", "Swedish", "Svenska", "CP1252", "sv", true },
  70. { "turkish", "Turkish", "Türkçe", "CP1254", "tr", true },
  71. { "ukrainian", "Ukrainian", "Українська", "CP1251", "uk", true },
  72. { "other_cp1250", "Other (East European)", "", "CP1250", "", false },
  73. { "other_cp1251", "Other (Cyrillic Script)", "", "CP1251", "", false },
  74. { "other_cp1252", "Other (West European)", "", "CP1252", "", false }
  75. } };
  76. static_assert(languages.size() == static_cast<size_t>(ELanguages::COUNT), "Languages array is missing a value!");
  77. return languages;
  78. }
  79. inline const Options & getLanguageOptions(ELanguages language)
  80. {
  81. assert(language < ELanguages::COUNT);
  82. return getLanguageList()[static_cast<size_t>(language)];
  83. }
  84. inline const Options & getLanguageOptions(const std::string & language)
  85. {
  86. for(const auto & entry : getLanguageList())
  87. if(entry.identifier == language)
  88. return entry;
  89. static const Options emptyValue;
  90. assert(0);
  91. return emptyValue;
  92. }
  93. }