From 9e4927ece5448c94bc3f46f7be019c0ffe14a686 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 11 Oct 2012 17:29:04 -0400 Subject: Make LLTransUtil::parseStrings() merge all relevant strings.xml files. Until now, adding a xui/en/strings.xml file in any non-default skin meant you had to clone the entire file, editing only the particular entries you wanted to override. With this change, we load strings.xml file(s) from the default skin before loading the specified skin -- so a non-default skin can now provide a strings.xml file containing only the specific entries it wants to override. --- indra/llui/lltransutil.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'indra/llui/lltransutil.cpp') diff --git a/indra/llui/lltransutil.cpp b/indra/llui/lltransutil.cpp index 58fa8a0828..97a72b55e1 100644 --- a/indra/llui/lltransutil.cpp +++ b/indra/llui/lltransutil.cpp @@ -31,15 +31,27 @@ #include "lltrans.h" #include "lluictrlfactory.h" #include "llxmlnode.h" - +#include "lldir.h" bool LLTransUtil::parseStrings(const std::string& xml_filename, const std::set& default_args) { + // LLUICtrlFactory::getLayeredXMLNode() just calls + // gDirUtilp->findSkinnedFilenames(merge=false) and then passes the + // resulting paths to LLXMLNode::getLayeredXMLNode(). Bypass that and call + // LLXMLNode::getLayeredXMLNode() directly: we want merge=true. + std::vector paths = + gDirUtilp->findSkinnedFilenames(LLDir::XUI, xml_filename, true); + if (paths.empty()) + { + // xml_filename not found at all in any skin -- check whether entire + // path was passed (but I hope we no longer have callers who do that) + paths.push_back(xml_filename); + } LLXMLNodePtr root; - BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); + bool success = LLXMLNode::getLayeredXMLNode(root, paths); if (!success) { - llerrs << "Couldn't load string table" << llendl; + llerrs << "Couldn't load string table " << xml_filename << llendl; return false; } @@ -54,7 +66,7 @@ bool LLTransUtil::parseLanguageStrings(const std::string& xml_filename) if (!success) { - llerrs << "Couldn't load string table " << xml_filename << llendl; + llerrs << "Couldn't load localization table " << xml_filename << llendl; return false; } -- cgit v1.2.3 From 730d13a76a4b06e6dbdd4bd5829a90bcb98b52b3 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 11 Oct 2012 19:51:07 -0400 Subject: Change LLDir::findSkinnedFilenames() to use enum instead of bool. At Richard's suggestion, changed the bool merge parameter to new enum ESkinConstraint with values CURRENT_SKIN and ALL_SKINS. This clarifies what we're requesting at the point of the call. --- indra/llui/lltransutil.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/llui/lltransutil.cpp') diff --git a/indra/llui/lltransutil.cpp b/indra/llui/lltransutil.cpp index 97a72b55e1..3b7e737dea 100644 --- a/indra/llui/lltransutil.cpp +++ b/indra/llui/lltransutil.cpp @@ -36,11 +36,12 @@ bool LLTransUtil::parseStrings(const std::string& xml_filename, const std::set& default_args) { // LLUICtrlFactory::getLayeredXMLNode() just calls - // gDirUtilp->findSkinnedFilenames(merge=false) and then passes the - // resulting paths to LLXMLNode::getLayeredXMLNode(). Bypass that and call - // LLXMLNode::getLayeredXMLNode() directly: we want merge=true. + // gDirUtilp->findSkinnedFilenames(constraint=LLDir::CURRENT_SKIN) and + // then passes the resulting paths to LLXMLNode::getLayeredXMLNode(). + // Bypass that and call LLXMLNode::getLayeredXMLNode() directly: we want + // constraint=LLDir::ALL_SKINS. std::vector paths = - gDirUtilp->findSkinnedFilenames(LLDir::XUI, xml_filename, true); + gDirUtilp->findSkinnedFilenames(LLDir::XUI, xml_filename, LLDir::ALL_SKINS); if (paths.empty()) { // xml_filename not found at all in any skin -- check whether entire -- cgit v1.2.3 From 6ca37068080e3b26e5cb163dfd874bc0e2f4c837 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 12 Oct 2012 08:42:18 -0400 Subject: LLUICtrlFactory::getLayeredXMLNode() gets LLDir::ESkinConstraint. At this point, LLUICtrlFactory::getLayeredXMLNode() is a pretty thin wrapper around LLDir::findSkinnedFilenames() and LLXMLNode::getLayeredXMLNode(). Until now, LLUICtrlFactory::getLayeredXMLNode() passed (by default) LLDir::CURRENT_SKIN to LLDir::findSkinnedFilenames(). But that meant that a caller such as LLTransUtil::parseStrings() that wants almost the same functionality, but with LLDir::ALL_SKINS instead, had to clone the logic from LLUICtrlFactory::getLayeredXMLNode(). Allowing its caller to pass the desired LLDir::ESkinConstraint enum value eliminates the need to clone its logic. Remove cloned logic from LLTransUtil::parseStrings(). --- indra/llui/lltransutil.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'indra/llui/lltransutil.cpp') diff --git a/indra/llui/lltransutil.cpp b/indra/llui/lltransutil.cpp index 3b7e737dea..80d079cbc8 100644 --- a/indra/llui/lltransutil.cpp +++ b/indra/llui/lltransutil.cpp @@ -35,21 +35,13 @@ bool LLTransUtil::parseStrings(const std::string& xml_filename, const std::set& default_args) { - // LLUICtrlFactory::getLayeredXMLNode() just calls - // gDirUtilp->findSkinnedFilenames(constraint=LLDir::CURRENT_SKIN) and - // then passes the resulting paths to LLXMLNode::getLayeredXMLNode(). - // Bypass that and call LLXMLNode::getLayeredXMLNode() directly: we want - // constraint=LLDir::ALL_SKINS. - std::vector paths = - gDirUtilp->findSkinnedFilenames(LLDir::XUI, xml_filename, LLDir::ALL_SKINS); - if (paths.empty()) - { - // xml_filename not found at all in any skin -- check whether entire - // path was passed (but I hope we no longer have callers who do that) - paths.push_back(xml_filename); - } LLXMLNodePtr root; - bool success = LLXMLNode::getLayeredXMLNode(root, paths); + // Pass LLDir::ALL_SKINS to load a composite of all the individual string + // definitions in the default skin and the current skin. This means an + // individual skin can provide an xml_filename that overrides only a + // subset of the available string definitions; any string definition not + // overridden by that skin will be sought in the default skin. + bool success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root, LLDir::ALL_SKINS); if (!success) { llerrs << "Couldn't load string table " << xml_filename << llendl; -- cgit v1.2.3