diff options
author | James Cook <james@lindenlab.com> | 2009-10-03 23:40:28 +0000 |
---|---|---|
committer | James Cook <james@lindenlab.com> | 2009-10-03 23:40:28 +0000 |
commit | ada0f4fa221f2c7070fb02a2b7ff903bdde11c45 (patch) | |
tree | 0ede83511c304110138c01d16da2fff55162ef31 /indra/llxuixml | |
parent | b1a280841e1823a19658923a8eefeb67d1d70735 (diff) |
Merge inspectors UI project, gooey-4, into viewer-2 trunk. Added new tooltips to 3D avatars, 2D avatar names, and 3D objects. Refactors tooltips and text boxes, line editors, and text editors. Breaks LLExpandableTextBox, but a fix is coming.
Resolved conflicts in lltexteditor.cpp, llchatitemscontainerctrl.cpp, llchatmsgbox.cpp, llfloaterbuycurrency.cpp, llnearbychat.cpp, floater_buy_currency.xml, and ru/strings.xml
Merging revisions 134925-135157 of svn+ssh://svn.lindenlab.com/svn/linden/branches/gooey/gooey-4 into C:\source\viewer-2.0.0-3, respecting ancestry
Diffstat (limited to 'indra/llxuixml')
-rw-r--r-- | indra/llxuixml/llinitparam.h | 23 | ||||
-rw-r--r-- | indra/llxuixml/lltrans.cpp | 65 | ||||
-rw-r--r-- | indra/llxuixml/lltrans.h | 6 |
3 files changed, 85 insertions, 9 deletions
diff --git a/indra/llxuixml/llinitparam.h b/indra/llxuixml/llinitparam.h index baa782916e..88bc430504 100644 --- a/indra/llxuixml/llinitparam.h +++ b/indra/llxuixml/llinitparam.h @@ -1568,11 +1568,11 @@ namespace LLInitParam public Param { public: - typedef BlockValue<T> self_t; - typedef Block<TypedParam<T, TypeValues<T>, false> > block_t; - typedef const T& value_const_ref_t; - typedef value_const_ref_t value_assignment_t; - typedef typename TypeValues<T>::KeyCache key_cache_t; + typedef BlockValue<T> self_t; + typedef Block<TypedParam<T, TypeValues<T>, false> > block_t; + typedef const T& value_const_ref_t; + typedef value_const_ref_t value_assignment_t; + typedef typename TypeValues<T>::KeyCache key_cache_t; BlockValue(BlockDescriptor& block_descriptor, const char* name, value_assignment_t value, ParamDescriptor::validation_func_t validate_func, S32 min_count, S32 max_count) : Param(block_descriptor.mCurrentBlockPtr), @@ -1754,11 +1754,16 @@ namespace LLInitParam protected: value_assignment_t get() const { - if (mData.mLastParamVersion < BaseBlock::getLastChangeVersion() && block_t::validateBlock(true)) + // if some parameters were provided, issue warnings on invalid blocks + if (Param::getProvided() && (mData.mLastParamVersion < BaseBlock::getLastChangeVersion())) { - mData.mValue = static_cast<const DERIVED*>(this)->getValueFromBlock(); - mData.clearKey(); - mData.mLastParamVersion = BaseBlock::getLastChangeVersion(); + // go ahead and issue warnings at this point if any param is invalid + if(block_t::validateBlock(false)) + { + mData.mValue = static_cast<const DERIVED*>(this)->getValueFromBlock(); + mData.clearKey(); + mData.mLastParamVersion = BaseBlock::getLastChangeVersion(); + } } return mData.mValue; diff --git a/indra/llxuixml/lltrans.cpp b/indra/llxuixml/lltrans.cpp index 2efc475f57..e974dbd0ba 100644 --- a/indra/llxuixml/lltrans.cpp +++ b/indra/llxuixml/lltrans.cpp @@ -194,3 +194,68 @@ bool LLTrans::findString(std::string &result, const std::string &xml_desc, const return false; } } + +//static +std::string LLTrans::getCountString(const std::string& language, const std::string& xml_desc, S32 count) +{ + // Compute which string identifier to use + const char* form = ""; + if (language == "ru") // Russian + { + // From GNU ngettext() + // Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2; + if (count % 10 == 1 + && count % 100 != 11) + { + // singular, "1 item" + form = "A"; + } + else if (count % 10 >= 2 + && count % 10 <= 4 + && (count % 100 < 10 || count % 100 >= 20) ) + { + // special case "2 items", "23 items", but not "13 items" + form = "B"; + } + else + { + // English-style plural, "5 items" + form = "C"; + } + } + else if (language == "fr" || language == "pt") // French, Brazilian Portuguese + { + // French and Portuguese treat zero as a singular "0 item" not "0 items" + if (count == 0 || count == 1) + { + form = "A"; + } + else + { + // English-style plural + form = "B"; + } + } + else // default + { + // languages like English with 2 forms, singular and plural + if (count == 1) + { + // "1 item" + form = "A"; + } + else + { + // "2 items", also use plural for "0 items" + form = "B"; + } + } + + // Translate that string + LLStringUtil::format_map_t args; + args["[COUNT]"] = llformat("%d", count); + + // Look up "AgeYearsB" or "AgeWeeksC" including the "form" + std::string key = llformat("%s%s", xml_desc.c_str(), form); + return getString(key, args); +} diff --git a/indra/llxuixml/lltrans.h b/indra/llxuixml/lltrans.h index 340d70e434..79df5802e5 100644 --- a/indra/llxuixml/lltrans.h +++ b/indra/llxuixml/lltrans.h @@ -80,6 +80,12 @@ public: static std::string getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args); static bool findString(std::string &result, const std::string &xml_desc, const LLStringUtil::format_map_t& args); + // Returns translated string with [COUNT] replaced with a number, following + // special per-language logic for plural nouns. For example, some languages + // may have different plurals for 0, 1, 2 and > 2. + // See "AgeWeeksA", "AgeWeeksB", etc. in strings.xml for examples. + static std::string getCountString(const std::string& language, const std::string& xml_desc, S32 count); + /** * @brief Returns a translated string * @param xml_desc String's description |