Fixed: #1129 Implement missing CI18N::getLanguageCodes and CI18N::getLanguageNames methods

hg/feature/sound
kervala 14 years ago
parent 3bdc155cd5
commit 24eb87f999

@ -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;
}
const std::vector<ucstring> &CI18N::getLanguageNames()
{
return _LanguageNames;
}
const std::vector<std::string> &CI18N::getLanguageCodes()
void CI18N::initLanguages()
{
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])));
}
_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()
{
initLanguages();
return _LanguageCodes;
}

Loading…
Cancel
Save