1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- //
- // LocalizationMgr.hpp
- // redream_runtime
- //
- // Created by ZhengSong on 2022/7/11.
- //
- #ifndef LocalizationMgr_h
- #define LocalizationMgr_h
- #include "cocos2d.h"
- NS_CC_BEGIN
- class LocalizationMgr {
- public:
- static LocalizationMgr* getInstance();
- bool init();
- /* 通过key转化为当前国家的语言
- * @param Label的string value
- * @param 本地化文件
- */
-
- /// 通过key转化为当前国家的语言
- /// @param key key-value
- /// @param fileName 本地化配置文件
- std::string getString(const std::string &key, const std::string &fileName);
- /* 设置当前国家的语言
- * @param code 国家编码
- */
- void setCurrentLanguageCode(const std::string& code);
- std::string getCurrentLanguageCode() const;
- private:
-
- /// 缓存读过的配置文件
- /// @param fileName fileName
- const cocos2d::ValueMap _getFileFromCache(const std::string& fileName);
- private:
- std::unordered_map<std::string, ValueMap> _plistMap;
- std::string _currentLanguageCode; //默认值为设备当前语言
- };
- NS_CC_END
- #endif /* LocalizationMgr_hpp */
|