Allow newlines in translation keys.

This commit is contained in:
The Dax committed 2013-08-26 13:53:52 -04:00
1 parent 1ac2bd895d
commit cec2e6cea9
1 file changed
+6 -2
+6 -2
View File
@@ -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;
}
}