Fixed: #1129 Implement missing CI18N::getLanguageCodes and CI18N::getLanguageNames methods
This commit is contained in:
parent
3bdc155cd5
commit
24eb87f999
2 changed files with 24 additions and 27 deletions
|
@ -241,6 +241,9 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/// Init _LanguageCodes and _LanguageNames
|
||||||
|
static void initLanguages();
|
||||||
|
|
||||||
static bool loadFileIntoMap(const std::string &filename, StrMapContainer &dest);
|
static bool loadFileIntoMap(const std::string &filename, StrMapContainer &dest);
|
||||||
|
|
||||||
/// The internal read function, it does the real job of readTextFile
|
/// The internal read function, it does the real job of readTextFile
|
||||||
|
|
|
@ -39,40 +39,34 @@ void CI18N::setLoadProxy(ILoadProxy *loadProxy)
|
||||||
_LoadProxy = loadProxy;
|
_LoadProxy = loadProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CI18N::initLanguages()
|
||||||
|
{
|
||||||
|
if (!_LanguagesNamesLoaded)
|
||||||
|
{
|
||||||
|
_LanguageCodes.push_back("en");
|
||||||
|
_LanguageCodes.push_back("fr");
|
||||||
|
_LanguageCodes.push_back("de");
|
||||||
|
_LanguageCodes.push_back("ru");
|
||||||
|
|
||||||
|
_LanguageNames.push_back("English");
|
||||||
|
_LanguageNames.push_back("French");
|
||||||
|
_LanguageNames.push_back("German");
|
||||||
|
_LanguageNames.push_back("Russian");
|
||||||
|
|
||||||
|
_LanguagesNamesLoaded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<ucstring> &CI18N::getLanguageNames()
|
const std::vector<ucstring> &CI18N::getLanguageNames()
|
||||||
{
|
{
|
||||||
|
initLanguages();
|
||||||
|
|
||||||
return _LanguageNames;
|
return _LanguageNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<std::string> &CI18N::getLanguageCodes()
|
const std::vector<std::string> &CI18N::getLanguageCodes()
|
||||||
{
|
{
|
||||||
if (!_LanguagesNamesLoaded)
|
initLanguages();
|
||||||
{
|
|
||||||
std::vector<std::string> files;
|
|
||||||
|
|
||||||
// search all .uxt files
|
|
||||||
CPath::getFileList("uxt", files);
|
|
||||||
|
|
||||||
// if not uxt found, use default languages
|
|
||||||
if (files.empty())
|
|
||||||
{
|
|
||||||
_LanguageCodes.clear();
|
|
||||||
_LanguageCodes.push_back("en");
|
|
||||||
_LanguageCodes.push_back("fr");
|
|
||||||
_LanguageCodes.push_back("de");
|
|
||||||
_LanguageCodes.push_back("ru");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// add all languages found
|
|
||||||
for(uint i = 0; i < files.size(); ++i)
|
|
||||||
{
|
|
||||||
_LanguageCodes.push_back(toLower(CFile::getFilenameWithoutExtension(files[i])));
|
|
||||||
}
|
|
||||||
|
|
||||||
_LanguagesNamesLoaded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _LanguageCodes;
|
return _LanguageCodes;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue