summaryrefslogtreecommitdiff
path: root/indra/llui/lltrans.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llui/lltrans.cpp')
-rw-r--r--indra/llui/lltrans.cpp60
1 files changed, 56 insertions, 4 deletions
diff --git a/indra/llui/lltrans.cpp b/indra/llui/lltrans.cpp
index 4d4ff4236d..a1a8feedaa 100644
--- a/indra/llui/lltrans.cpp
+++ b/indra/llui/lltrans.cpp
@@ -36,6 +36,7 @@
#include <map>
LLTrans::template_map_t LLTrans::sStringTemplates;
+LLTrans::template_map_t LLTrans::sDefaultStringTemplates;
LLStringUtil::format_map_t LLTrans::sDefaultArgs;
struct StringDef : public LLInitParam::Block<StringDef>
@@ -76,7 +77,7 @@ bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& defa
LL_ERRS() << "Problem reading strings: " << xml_filename << LL_ENDL;
return false;
}
-
+ static bool default_strings_init = false;
sStringTemplates.clear();
sDefaultArgs.clear();
@@ -86,7 +87,10 @@ bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& defa
{
LLTransTemplate xml_template(it->name, it->value);
sStringTemplates[xml_template.mName] = xml_template;
-
+ if (!default_strings_init)
+ {
+ sDefaultStringTemplates[xml_template.mName] = xml_template;
+ }
std::set<std::string>::const_iterator iter = default_args.find(xml_template.mName);
if (iter != default_args.end())
{
@@ -96,6 +100,7 @@ bool LLTrans::parseStrings(LLXMLNodePtr &root, const std::set<std::string>& defa
sDefaultArgs[name] = xml_template.mText;
}
}
+ default_strings_init = true;
return true;
}
@@ -138,12 +143,17 @@ bool LLTrans::parseLanguageStrings(LLXMLNodePtr &root)
static LLTrace::BlockTimerStatHandle FTM_GET_TRANS("Translate string");
//static
-std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args)
+std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args, bool def_string)
{
// Don't care about time as much as call count. Make sure we're not
// calling LLTrans::getString() in an inner loop. JC
LL_RECORD_BLOCK_TIME(FTM_GET_TRANS);
+ if (def_string)
+ {
+ return getDefString(xml_desc, msg_args);
+ }
+
template_map_t::iterator iter = sStringTemplates.find(xml_desc);
if (iter != sStringTemplates.end())
{
@@ -161,13 +171,38 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::
}
}
+//static
+std::string LLTrans::getDefString(const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args)
+{
+ template_map_t::iterator iter = sDefaultStringTemplates.find(xml_desc);
+ if (iter != sDefaultStringTemplates.end())
+ {
+ std::string text = iter->second.mText;
+ LLStringUtil::format_map_t args = sDefaultArgs;
+ args.insert(msg_args.begin(), msg_args.end());
+ LLStringUtil::format(text, args);
+
+ return text;
+ }
+ else
+ {
+ LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL;
+ return "MissingString(" + xml_desc + ")";
+ }
+}
+
//static
-std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args)
+std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args, bool def_string)
{
// Don't care about time as much as call count. Make sure we're not
// calling LLTrans::getString() in an inner loop. JC
LL_RECORD_BLOCK_TIME(FTM_GET_TRANS);
+ if (def_string)
+ {
+ return getDefString(xml_desc, msg_args);
+ }
+
template_map_t::iterator iter = sStringTemplates.find(xml_desc);
if (iter != sStringTemplates.end())
{
@@ -182,6 +217,23 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLSD& msg_args
}
}
+//static
+std::string LLTrans::getDefString(const std::string &xml_desc, const LLSD& msg_args)
+{
+ template_map_t::iterator iter = sDefaultStringTemplates.find(xml_desc);
+ if (iter != sDefaultStringTemplates.end())
+ {
+ std::string text = iter->second.mText;
+ LLStringUtil::format(text, msg_args);
+ return text;
+ }
+ else
+ {
+ LL_WARNS_ONCE("configuration") << "Missing String in strings.xml: [" << xml_desc << "]" << LL_ENDL;
+ return "MissingString(" + xml_desc + ")";
+ }
+}
+
//static
bool LLTrans::findString(std::string &result, const std::string &xml_desc, const LLStringUtil::format_map_t& msg_args)
{