* Holds localized text data. * * It is used with data generated from Translations/ with the python generation scripts. * It's used with a header file that specifies the indexes, and generated text files (.i18n) */
| 12 | * It's used with a header file that specifies the indexes, and generated text files (.i18n) |
| 13 | */ |
| 14 | class TextResources { |
| 15 | |
| 16 | std::vector<std::string> data; |
| 17 | std::string path; |
| 18 | static std::string ERROR_RESULT; |
| 19 | |
| 20 | public: |
| 21 | /** |
| 22 | * @param[in] path |
| 23 | */ |
| 24 | TextResources(const std::string& path) : path(path) {} |
| 25 | |
| 26 | const std::string& get(const int index) const { |
| 27 | if (index < data.size()) { |
| 28 | return data[index]; |
| 29 | } else { |
| 30 | return ERROR_RESULT; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | template <typename EnumType> |
| 35 | const std::string& get(EnumType value) const { return get(static_cast<int>(value)); } |
| 36 | |
| 37 | const std::string& operator[](const int index) const { return get(index); } |
| 38 | |
| 39 | template <typename EnumType> |
| 40 | const std::string& operator[](const EnumType index) const { return get(index); } |
| 41 | |
| 42 | /** |
| 43 | * Load or reload an i18n file with the system's current locale settings. |
| 44 | * @return true on success |
| 45 | */ |
| 46 | bool load(); |
| 47 | }; |
| 48 | |
| 49 | } |