From 46d68b8d50bb6022c8755dcbc7bdc087f900c499 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 3 Dec 2011 03:35:36 +0000 Subject: [PATCH] -updated so all languages can take default values from the default language --- source/glest_game/global/lang.cpp | 11 ++++++++++- source/glest_game/global/lang.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/source/glest_game/global/lang.cpp b/source/glest_game/global/lang.cpp index 8b95a0e9..d74a437f 100644 --- a/source/glest_game/global/lang.cpp +++ b/source/glest_game/global/lang.cpp @@ -262,9 +262,17 @@ bool Lang::isLanguageLocal(string compareLanguage) const { return (compareLanguage == language); } +string Lang::parseResult(const string &key, const string &value) { + if(value != "$USE_DEFAULT_LANGUAGE_VALUE") { + return value; + } + string result = Lang::get(key, DEFAULT_LANGUAGE); + return result; +} string Lang::get(const string &s, string uselanguage, bool fallbackToDefault) { try { string result = ""; + if(uselanguage != "") { if(otherLanguageStrings.find(uselanguage) == otherLanguageStrings.end()) { loadStrings(uselanguage, otherLanguageStrings[uselanguage], false); @@ -276,7 +284,8 @@ string Lang::get(const string &s, string uselanguage, bool fallbackToDefault) { result = strings.getString(s); replaceAll(result, "\\n", "\n"); } - return result; + + return parseResult(s, result);; } catch(exception &ex) { if(strings.getpath() != "") { diff --git a/source/glest_game/global/lang.h b/source/glest_game/global/lang.h index 91cf42d3..c299a0ed 100644 --- a/source/glest_game/global/lang.h +++ b/source/glest_game/global/lang.h @@ -42,6 +42,8 @@ private: bool fileMatchesISO630Code(string uselanguage, string testLanguageFile); string getNativeLanguageName(string uselanguage, string testLanguageFile); + string parseResult(const string &key, const string &value); + public: static Lang &getInstance();