diff options
author | Mike Antipov <mantipov@productengine.com> | 2010-07-14 16:25:17 +0300 |
---|---|---|
committer | Mike Antipov <mantipov@productengine.com> | 2010-07-14 16:25:17 +0300 |
commit | 14724102f352ec9f79506db173ee952ef5412cf8 (patch) | |
tree | e704d04980d2260da95185d30bb9a8ad63e0e1e7 | |
parent | 0f169e180667175ba298f8fdf1e7a45db70d89fd (diff) |
EXT-8319 FIXED Added method to localize inventory categories having predefined names, updated predefined keys for "Male - Get lost" and "Female - Get lost".
There were two issues:
* "Male - Get lost" and "Female - Get lost" gestures have by 2 spaces before "-" in their names.
* Folders were not processed to be localize. This was not implemented correctly in EXT-7051.
Reviewed by Vadim Savchuk at https://codereview.productengine.com/secondlife/r/753/
--HG--
branch : product-engine
-rw-r--r-- | indra/newview/llinventorymodel.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.cpp | 43 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.h | 5 |
3 files changed, 38 insertions, 13 deletions
diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 236ed9bbd1..13e5cb516e 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -1254,6 +1254,9 @@ void LLInventoryModel::addCategory(LLViewerInventoryCategory* category) //llinfos << "LLInventoryModel::addCategory()" << llendl; if(category) { + // try to localize default names first. See EXT-8319, EXT-7051. + category->localizeName(); + // Insert category uniquely into the map mCategoryMap[category->getUUID()] = category; // LLPointer will deref and delete the old one //mInventory[category->getUUID()] = category; diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index cbc86c89cc..bea21931bd 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -67,7 +67,7 @@ #include "llsidepanelappearance.h" ///---------------------------------------------------------------------------- -/// Helper class to store special inventory item names +/// Helper class to store special inventory item names and their localized values. ///---------------------------------------------------------------------------- class LLLocalizedInventoryItemsDictionary : public LLSingleton<LLLocalizedInventoryItemsDictionary> { @@ -108,7 +108,7 @@ public: //male mInventoryItemsDict["Male - Excuse me"] = LLTrans::getString("Male - Excuse me"); - mInventoryItemsDict["Male - Get lost"] = LLTrans::getString("Male - Get lost"); + mInventoryItemsDict["Male - Get lost"] = LLTrans::getString("Male - Get lost"); // double space after Male. EXT-8319 mInventoryItemsDict["Male - Blow kiss"] = LLTrans::getString("Male - Blow kiss"); mInventoryItemsDict["Male - Boo"] = LLTrans::getString("Male - Boo"); mInventoryItemsDict["Male - Bored"] = LLTrans::getString("Male - Bored"); @@ -121,7 +121,7 @@ public: //female mInventoryItemsDict["Female - Excuse me"] = LLTrans::getString("Female - Excuse me"); - mInventoryItemsDict["Female - Get lost"] = LLTrans::getString("Female - Get lost"); + mInventoryItemsDict["Female - Get lost"] = LLTrans::getString("Female - Get lost"); // double space after Female. EXT-8319 mInventoryItemsDict["Female - Blow kiss"] = LLTrans::getString("Female - Blow kiss"); mInventoryItemsDict["Female - Boo"] = LLTrans::getString("Female - Boo"); mInventoryItemsDict["Female - Bored"] = LLTrans::getString("Female - Bored"); @@ -133,6 +133,27 @@ public: mInventoryItemsDict["Female - Wow"] = LLTrans::getString("Female - Wow"); } + + /** + * Finds passed name in dictionary and replaces it with found localized value. + * + * @param object_name - string to be localized. + * @return true if passed name was found and localized, false otherwise. + */ + bool localizeInventoryObjectName(std::string& object_name) + { + LL_DEBUGS("InventoryLocalize") << "Searching for localization: " << object_name << LL_ENDL; + + std::map<std::string, std::string>::const_iterator dictionary_iter = mInventoryItemsDict.find(object_name); + + bool found = dictionary_iter != mInventoryItemsDict.end(); + if(found) + { + object_name = dictionary_iter->second; + LL_DEBUGS("InventoryLocalize") << "Found, new name is: " << object_name << LL_ENDL; + } + return found; + } }; @@ -391,16 +412,7 @@ BOOL LLViewerInventoryItem::unpackMessage(LLMessageSystem* msg, const char* bloc { BOOL rv = LLInventoryItem::unpackMessage(msg, block, block_num); - std::string localized_str; - - std::map<std::string, std::string>::const_iterator dictionary_iter; - - dictionary_iter = LLLocalizedInventoryItemsDictionary::getInstance()->mInventoryItemsDict.find(mName); - - if(dictionary_iter != LLLocalizedInventoryItemsDictionary::getInstance()->mInventoryItemsDict.end()) - { - mName = dictionary_iter->second; - } + LLLocalizedInventoryItemsDictionary::getInstance()->localizeInventoryObjectName(mName); mIsComplete = TRUE; return rv; @@ -820,6 +832,11 @@ void LLViewerInventoryCategory::changeType(LLFolderType::EType new_folder_type) gInventory.addChangedMask(LLInventoryObserver::LABEL, folder_id); } +void LLViewerInventoryCategory::localizeName() +{ + LLLocalizedInventoryItemsDictionary::getInstance()->localizeInventoryObjectName(mName); +} + ///---------------------------------------------------------------------------- /// Local function definitions ///---------------------------------------------------------------------------- diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index 1dd6597388..ef3586537b 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -229,6 +229,11 @@ public: bool importFileLocal(LLFILE* fp); void determineFolderType(); void changeType(LLFolderType::EType new_folder_type); + +private: + friend class LLInventoryModel; + void localizeName(); // intended to be called from the LLInventoryModel + protected: LLUUID mOwnerID; S32 mVersion; |