From 24eb87f9990e5973f78a226527c700da3fa78c4b Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 18 Oct 2010 19:34:20 +0200 Subject: [PATCH] Fixed: #1129 Implement missing CI18N::getLanguageCodes and CI18N::getLanguageNames methods --- code/nel/include/nel/misc/i18n.h | 3 ++ code/nel/src/misc/i18n.cpp | 48 ++++++++++++++------------------ 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/code/nel/include/nel/misc/i18n.h b/code/nel/include/nel/misc/i18n.h index 6778efcc6..4a1984d65 100644 --- a/code/nel/include/nel/misc/i18n.h +++ b/code/nel/include/nel/misc/i18n.h @@ -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 diff --git a/code/nel/src/misc/i18n.cpp b/code/nel/src/misc/i18n.cpp index 94e41a06a..e76dc73eb 100644 --- a/code/nel/src/misc/i18n.cpp +++ b/code/nel/src/misc/i18n.cpp @@ -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 &CI18N::getLanguageNames() { + initLanguages(); + return _LanguageNames; } const std::vector &CI18N::getLanguageCodes() { - if (!_LanguagesNamesLoaded) - { - std::vector 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; }