#ifndef COMPONENTS_L10N_MANAGER_H #define COMPONENTS_L10N_MANAGER_H #include #include namespace VFS { class Manager; } namespace l10n { class Manager { public: Manager(const VFS::Manager* vfs) : mVFS(vfs) { } void dropCache() { mCache.clear(); } void setPreferredLocales(const std::vector& locales); const std::vector& getPreferredLocales() const { return mPreferredLocales; } void setGmstLoader(std::function fn) { mGmstLoader = std::move(fn); } std::shared_ptr getContext( const std::string& contextName, const std::string& fallbackLocale = "en"); std::string getMessage(const std::string& contextName, std::string_view key) { return getContext(contextName)->formatMessage(key, {}, {}); } private: void readLangData(const std::string& name, MessageBundles& ctx, const icu::Locale& lang); void updateContext(const std::string& name, MessageBundles& ctx); const VFS::Manager* mVFS; std::vector mPreferredLocales; std::map, std::shared_ptr> mCache; std::function mGmstLoader; }; } #endif // COMPONENTS_L10N_MANAGER_H