diff --git a/source/glest_game/global/lang.cpp b/source/glest_game/global/lang.cpp index 61b663ff0..f70d9dc85 100644 --- a/source/glest_game/global/lang.cpp +++ b/source/glest_game/global/lang.cpp @@ -72,7 +72,9 @@ void Lang::loadScenarioStrings(const string &scenarioDir, const string &scenario string Lang::get(const string &s){ try{ - return strings.getString(s); + string result = strings.getString(s); + replaceAll(result, "\\n", "\n"); + return result; } catch(exception &){ return "???" + s + "???"; diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 79abded29..24de528e8 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -448,6 +448,10 @@ int glestMain(int argc, char** argv){ //throw runtime_error("test!"); //ExceptionHandler::DisplayMessage("test!", false); + //Lang &lang= Lang::getInstance(); + //string test = lang.get("ExitGameServer?"); + //printf("[%s]",test.c_str()); + //main loop while(Window::handleEvent()){ program->loop(); diff --git a/source/shared_lib/include/platform/common/platform_common.h b/source/shared_lib/include/platform/common/platform_common.h index 566c09542..650b23a9c 100644 --- a/source/shared_lib/include/platform/common/platform_common.h +++ b/source/shared_lib/include/platform/common/platform_common.h @@ -122,6 +122,8 @@ void restoreVideoMode(bool exitingApp=false); bool EndsWith(const string &str, const string& key); +string replaceAll(string& context, const string& from, const string& to); + int getScreenW(); int getScreenH(); diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 0386117d6..9cc0da075 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -831,6 +831,16 @@ bool isKeyDown(int virtualKey) { } +string replaceAll(string& context, const string& from, const string& to) { + size_t lookHere = 0; + size_t foundHere; + while((foundHere = context.find(from, lookHere)) != string::npos) { + context.replace(foundHere, from.size(), to); + lookHere = foundHere + to.size(); + } + return context; +} + // ===================================== // ModeInfo // =====================================