mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-29 12:20:53 +00:00
Fixed: #1129 Implement missing CI18N::getLanguageCodes and CI18N::getLanguageNames methods
This commit is contained in:
parent
99ac3fb701
commit
3956d3a8f9
2 changed files with 24 additions and 27 deletions
|
@ -241,6 +241,9 @@ private:
|
|||
|
||||
private:
|
||||
|
||||
/// Init _LanguageCodes and _LanguageNames
|
||||
static void initLanguages();
|
||||
|
||||
static bool loadFileIntoMap(const std::string &filename, StrMapContainer &dest);
|
||||
|
||||
/// The internal read function, it does the real job of readTextFile
|
||||
|
|
|
@ -39,40 +39,34 @@ void CI18N::setLoadProxy(ILoadProxy *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()
|
||||
{
|
||||
initLanguages();
|
||||
|
||||
return _LanguageNames;
|
||||
}
|
||||
|
||||
const std::vector<std::string> &CI18N::getLanguageCodes()
|
||||
{
|
||||
if (!_LanguagesNamesLoaded)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
initLanguages();
|
||||
|
||||
return _LanguageCodes;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue