Languages.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. ENGLISH,
  16. FRENCH,
  17. GERMAN,
  18. POLISH,
  19. RUSSIAN,
  20. UKRAINIAN,
  21. COUNT
  22. };
  23. struct Options
  24. {
  25. /// string identifier (ascii, lower-case), e.g. "english"
  26. std::string identifier;
  27. /// human-readable name of language in English
  28. std::string nameEnglish;
  29. /// human-readable name of language in its own language
  30. std::string nameNative;
  31. /// encoding that is used by H3 for this language
  32. std::string encoding;
  33. /// VCMI is capable of detecting H3 install in this language
  34. bool hasDetection = false;
  35. /// VCMI supports translations into this language
  36. bool hasTranslation = false;
  37. };
  38. inline auto const & getLanguageList( )
  39. {
  40. static const std::array<Options, 6> languages
  41. { {
  42. { "english", "English", "English", "CP1252", true, true },
  43. { "french", "French", "Français", "CP1252", true, false },
  44. { "german", "German", "Deutsch", "CP1252", true, true },
  45. { "polish", "Polish", "Polski", "CP1250", true, true },
  46. { "russian", "Russian", "Русский", "CP1251", true, true },
  47. { "ukrainian", "Ukrainian", "Українська", "CP1251", true, true }
  48. } };
  49. static_assert (languages.size() == static_cast<size_t>(ELanguages::COUNT), "Languages array is missing a value!" );
  50. return languages;
  51. }
  52. inline const Options & getLanguageOptions( ELanguages language )
  53. {
  54. assert(language < ELanguages::COUNT);
  55. return getLanguageList()[static_cast<size_t>(language)];
  56. }
  57. inline const Options & getLanguageOptions( std::string language )
  58. {
  59. for (auto const & entry : getLanguageList())
  60. if (entry.identifier == language)
  61. return entry;
  62. static const Options emptyValue;
  63. assert(0);
  64. return emptyValue;
  65. }
  66. }