Languages.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. CHINESE,
  16. ENGLISH,
  17. FRENCH,
  18. GERMAN,
  19. KOREAN, // currently has no translations or detection
  20. POLISH,
  21. RUSSIAN,
  22. SPANISH,
  23. UKRAINIAN,
  24. // Pseudo-languages, that have no translations but can define H3 encoding to use
  25. OTHER_CP1250,
  26. OTHER_CP1251,
  27. OTHER_CP1252,
  28. COUNT
  29. };
  30. struct Options
  31. {
  32. /// string identifier (ascii, lower-case), e.g. "english"
  33. std::string identifier;
  34. /// human-readable name of language in English
  35. std::string nameEnglish;
  36. /// human-readable name of language in its own language
  37. std::string nameNative;
  38. /// encoding that is used by H3 for this language
  39. std::string encoding;
  40. /// primary IETF language tag
  41. std::string tagIETF;
  42. /// VCMI is capable of detecting H3 install in this language
  43. bool hasDetection = false;
  44. /// VCMI supports translations into this language
  45. bool hasTranslation = false;
  46. };
  47. inline const auto & getLanguageList()
  48. {
  49. static const std::array<Options, 12> languages
  50. { {
  51. { "chinese", "Chinese", "简体中文", "GBK", "zh", true, true }, // Note: actually Simplified Chinese
  52. { "english", "English", "English", "CP1252", "en", true, true },
  53. { "french", "French", "Français", "CP1252", "fr", true, true },
  54. { "german", "German", "Deutsch", "CP1252", "de", true, true },
  55. { "korean", "Korean", "한국어", "CP949", "ko", false, false },
  56. { "polish", "Polish", "Polski", "CP1250", "pl", true, true },
  57. { "russian", "Russian", "Русский", "CP1251", "ru", true, true },
  58. { "spanish", "Spanish", "Español", "CP1252", "es", false, true },
  59. { "ukrainian", "Ukrainian", "Українська", "CP1251", "uk", true, true },
  60. { "other_cp1250", "Other (East European)", "", "CP1251", "", false, false },
  61. { "other_cp1251", "Other (Cyrillic Script)", "", "CP1250", "", false, false },
  62. { "other_cp1252", "Other (West European)", "", "CP1252", "", false, false }
  63. } };
  64. static_assert(languages.size() == static_cast<size_t>(ELanguages::COUNT), "Languages array is missing a value!");
  65. return languages;
  66. }
  67. inline const Options & getLanguageOptions(ELanguages language)
  68. {
  69. assert(language < ELanguages::COUNT);
  70. return getLanguageList()[static_cast<size_t>(language)];
  71. }
  72. inline const Options & getLanguageOptions(const std::string & language)
  73. {
  74. for(const auto & entry : getLanguageList())
  75. if(entry.identifier == language)
  76. return entry;
  77. static const Options emptyValue;
  78. assert(0);
  79. return emptyValue;
  80. }
  81. }