From c50d54339f117e93feabe61aa1e3612a7a76d2b8 Mon Sep 17 00:00:00 2001 From: "beichen.liu" Date: Mon, 7 Mar 2016 09:52:53 +0800 Subject: [PATCH] Add localization arguments in simulator start args. --- .../lib/ProjectConfig/ProjectConfig.cpp | 25 +++++++++++++++++++ .../lib/ProjectConfig/ProjectConfig.h | 2 ++ 2 files changed, 27 insertions(+) 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;