AppLang.h 703 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // AppLang.h
  3. // Simulator
  4. //
  5. #ifndef __Simulator__AppLang__
  6. #define __Simulator__AppLang__
  7. #include "cocos2d.h"
  8. #include <map>
  9. #include "json/document-wrapper.h"
  10. #include "DeviceEx.h"
  11. #include "SimulatorExport.h"
  12. class CC_LIBSIM_DLL AppLang
  13. {
  14. public:
  15. static AppLang* getInstance();
  16. std::string getString(const std::string &lang, const std::string& key);
  17. protected:
  18. AppLang();
  19. void readLocalizationFile();
  20. bool _hasInit;
  21. std::string _localizationFileName;
  22. rapidjson::Document _docRootjson;
  23. };
  24. #define tr(key) AppLang::getInstance()->getString(player::DeviceEx::getInstance()->getCurrentUILangName(), key)
  25. #endif /* defined(__Simulator__AppLang__) */