diff --git a/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.cpp b/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.cpp index d649c93bf8..724748b44c 100644 --- a/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.cpp +++ b/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.cpp @@ -415,6 +415,12 @@ void ProjectConfig::parseCommandLine(const vector &args) vector pathes = split((*it), ';'); setFirstSearchPath(pathes); } + else if (arg.compare("-language-data-path") == 0) + { + ++it; + if (it == args.end()) break; + setLanguageDataPath(*it); + } ++it; } } @@ -646,6 +652,25 @@ const vector &ProjectConfig::getFirstSearchPath() const return _firstSearchPath; } +void ProjectConfig::setLanguageDataPath(const std::string &filePath) +{ + bool isBinary = true; + string jsonExtension = ".json"; + int exLength = jsonExtension.length(); + if (filePath.length() >= exLength && + (0 == filePath.compare(filePath.length() - exLength, exLength, jsonExtension))) + { + isBinary = false; + } + + cocostudio::ILocalizationManager* lm; + if (isBinary) + lm = cocostudio::BinLocalizationManager::getInstance(); + else + lm = cocostudio::JsonLocalizationManager::getInstance(); + lm->initLanguageData(filePath); + cocostudio::LocalizationHelper::setCurrentManager(lm, isBinary); +} bool ProjectConfig::isAppMenu() const { diff --git a/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h b/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h index 97c3d2382e..5946c63899 100644 --- a/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h +++ b/tools/simulator/libsimulator/lib/ProjectConfig/ProjectConfig.h @@ -107,6 +107,7 @@ public: const vector &getSearchPath() const; void setFirstSearchPath(const vector &args); const vector &getFirstSearchPath() const; + void setLanguageDataPath(const std::string &filePath); bool isAppMenu() const; bool isResizeWindow() const; @@ -137,6 +138,7 @@ private: string _bindAddress; vector _searchPath; vector _firstSearchPath; + string _languageDataPath; void normalize(); string replaceProjectDirToMacro(const string &path) const;