Languages.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. /// VCMI is capable of detecting H3 install in this language
  41. bool hasDetection = false;
  42. /// VCMI supports translations into this language
  43. bool hasTranslation = false;
  44. };
  45. inline const auto & getLanguageList()
  46. {
  47. static const std::array<Options, 12> languages
  48. { {
  49. { "chinese", "Chinese", "简体中文", "GBK", true, true }, // Note: actually Simplified Chinese
  50. { "english", "English", "English", "CP1252", true, true },
  51. { "french", "French", "Français", "CP1252", true, true },
  52. { "german", "German", "Deutsch", "CP1252", true, true },
  53. { "korean", "Korean", "한국어", "CP949", false, false },
  54. { "polish", "Polish", "Polski", "CP1250", true, true },
  55. { "russian", "Russian", "Русский", "CP1251", true, true },
  56. { "spanish", "Spanish", "Español", "CP1252", false, true },
  57. { "ukrainian", "Ukrainian", "Українська", "CP1251", true, true },
  58. { "other_cp1250", "Other (East European)", "", "CP1251", false, false },
  59. { "other_cp1251", "Other (Cyrillic Script)", "", "CP1250", false, false },
  60. { "other_cp1252", "Other (West European)", "", "CP1252", false, false }
  61. } };
  62. static_assert(languages.size() == static_cast<size_t>(ELanguages::COUNT), "Languages array is missing a value!");
  63. return languages;
  64. }
  65. inline const Options & getLanguageOptions(ELanguages language)
  66. {
  67. assert(language < ELanguages::COUNT);
  68. return getLanguageList()[static_cast<size_t>(language)];
  69. }
  70. inline const Options & getLanguageOptions(const std::string & language)
  71. {
  72. for(const auto & entry : getLanguageList())
  73. if(entry.identifier == language)
  74. return entry;
  75. static const Options emptyValue;
  76. assert(0);
  77. return emptyValue;
  78. }
  79. }