/** * @file Translation.h * @brief Translation class * @date May 9, 2017 * @author J.C.M. Raats * @copyright 2015 Dual Inventive Technology Centre B.V. * * Translation class. Use this class to get a message in a specific language */ #ifndef INCLUDE_DI_TRANSLATION_H_ #define INCLUDE_DI_TRANSLATION_H_ #include #include #include #include #include namespace Di { /** * @class Translation * * Translation class. Use this class to get a message in a specific language */ class Translation { public: explicit Translation(const std::string &basedir); std::string getDefaultTranslation(const std::string key, ...); std::string getTranslation(const std::string &key, const std::string langCode, ...); void reloadLanguage(const std::string &langCode); void setDefaultLanguage(const std::string &langCode); bool isDefaultLanguage(const std::string &langCode); private: mutable std::shared_timed_mutex __mutex; std::string __basedir; std::string __defaultLanguage; std::map> __translations; std::shared_ptr __getTranslationText(const std::string &key, const std::string &langCode); std::string __formatTranslationText(std::shared_ptr format, va_list args); std::shared_ptr __getTranslation(const std::string &key, const std::string &langCode); void __loadLanguage(const std::string &langCode, bool forceReload); std::string __getFilePath(const std::string &langCode); bool __fileExists(const std::string &filename); }; } // namespace Di #endif // INCLUDE_DI_TRANSLATION_H_