From cec2e6cea9eed78fb49e0d0a36d03182adabc5b0 Mon Sep 17 00:00:00 2001 From: The Dax Date: Mon, 26 Aug 2013 13:53:52 -0400 Subject: [PATCH] Allow newlines in translation keys. --- i18n/i18n.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/i18n/i18n.cpp b/i18n/i18n.cpp index 56061bd751..20e7fc547c 100644 --- a/i18n/i18n.cpp +++ b/i18n/i18n.cpp @@ -16,14 +16,18 @@ void I18NRepo::Clear() { } const char *I18NCategory::T(const char *key, const char *def) { - auto iter = map_.find(key); + // Replace the \n's with \\n's so that we can use newlines in ini key values. + std::string modifiedKey = key; + modifiedKey = ReplaceAll(modifiedKey, "\n", "\\n"); + + auto iter = map_.find(modifiedKey); if (iter != map_.end()) { return iter->second.text.c_str(); } else { if (def) missedKeyLog_[key] = def; else - missedKeyLog_[key] = key; + missedKeyLog_[key] = modifiedKey.c_str(); return def ? def : key; } }