Merge pull request #15190 from FrostPolaris/v3_localizeManage

Add localization arguments in simulator start args.

It's OK, merged
This commit is contained in:
xiaofeng11 2016-03-07 10:59:20 +08:00
commit f2c999441a
2 changed files with 27 additions and 0 deletions

View File

@ -415,6 +415,12 @@ void ProjectConfig::parseCommandLine(const vector<string> &args)
vector<string> 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<string> &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
{

View File

@ -107,6 +107,7 @@ public:
const vector<string> &getSearchPath() const;
void setFirstSearchPath(const vector<string> &args);
const vector<string> &getFirstSearchPath() const;
void setLanguageDataPath(const std::string &filePath);
bool isAppMenu() const;
bool isResizeWindow() const;
@ -137,6 +138,7 @@ private:
string _bindAddress;
vector<string> _searchPath;
vector<string> _firstSearchPath;
string _languageDataPath;
void normalize();
string replaceProjectDirToMacro(const string &path) const;