Languages.h 3.1 KB

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