Skip to content
Snippets Groups Projects
Commit e41912d3 authored by Yuri Chebotarev's avatar Yuri Chebotarev
Browse files

fix for EXT-5839 Creating a new wearable in a localized viewer attempts to use...

fix for EXT-5839 Creating a new wearable in a localized viewer attempts to use non-ascii characters for inventory types in some languages
reviewed Richard Nelson
https://codereview.productengine.com/secondlife/r/61/

--HG--
branch : product-engine
parent bb908fb7
No related branches found
No related tags found
No related merge requests found
...@@ -66,6 +66,40 @@ ...@@ -66,6 +66,40 @@
#include "llcommandhandler.h" #include "llcommandhandler.h"
#include "llviewermessage.h" #include "llviewermessage.h"
///----------------------------------------------------------------------------
/// Helper class to store special inventory item names
///----------------------------------------------------------------------------
class LLLocalizedInventoryItemsDictionary : public LLSingleton<LLLocalizedInventoryItemsDictionary>
{
public:
std::map<std::string, std::string> mInventoryItemsDict;
LLLocalizedInventoryItemsDictionary()
{
mInventoryItemsDict["New Shape"] = LLTrans::getString("New Shape");
mInventoryItemsDict["New Skin"] = LLTrans::getString("New Skin");
mInventoryItemsDict["New Hair"] = LLTrans::getString("New Hair");
mInventoryItemsDict["New Eyes"] = LLTrans::getString("New Eyes");
mInventoryItemsDict["New Shirt"] = LLTrans::getString("New Shirt");
mInventoryItemsDict["New Pants"] = LLTrans::getString("New Pants");
mInventoryItemsDict["New Shoes"] = LLTrans::getString("New Shoes");
mInventoryItemsDict["New Socks"] = LLTrans::getString("New Socks");
mInventoryItemsDict["New Jacket"] = LLTrans::getString("New Jacket");
mInventoryItemsDict["New Gloves"] = LLTrans::getString("New Gloves");
mInventoryItemsDict["New Undershirt"] = LLTrans::getString("New Undershirt");
mInventoryItemsDict["New Undershirt"] = LLTrans::getString("New Undershirt");
mInventoryItemsDict["New Skirt"] = LLTrans::getString("New Skirt");
mInventoryItemsDict["New Alpha"] = LLTrans::getString("New Alpha");
mInventoryItemsDict["New Tattoo"] = LLTrans::getString("New Tattoo");
mInventoryItemsDict["Invalid Wearable"] = LLTrans::getString("Invalid Wearable");
mInventoryItemsDict["New Script"] = LLTrans::getString("New Script");
mInventoryItemsDict["New Folder"] = LLTrans::getString("New Folder");
mInventoryItemsDict["Contents"] = LLTrans::getString("Contents");
}
};
///---------------------------------------------------------------------------- ///----------------------------------------------------------------------------
/// Local function declarations, constants, enums, and typedefs /// Local function declarations, constants, enums, and typedefs
///---------------------------------------------------------------------------- ///----------------------------------------------------------------------------
...@@ -316,6 +350,18 @@ BOOL LLViewerInventoryItem::unpackMessage(LLSD item) ...@@ -316,6 +350,18 @@ BOOL LLViewerInventoryItem::unpackMessage(LLSD item)
BOOL LLViewerInventoryItem::unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num) BOOL LLViewerInventoryItem::unpackMessage(LLMessageSystem* msg, const char* block, S32 block_num)
{ {
BOOL rv = LLInventoryItem::unpackMessage(msg, block, block_num); 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;
}
mIsComplete = TRUE; mIsComplete = TRUE;
return rv; return rv;
} }
...@@ -867,6 +913,25 @@ void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id, ...@@ -867,6 +913,25 @@ void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id,
U32 next_owner_perm, U32 next_owner_perm,
LLPointer<LLInventoryCallback> cb) LLPointer<LLInventoryCallback> cb)
{ {
//check if name is equal to one of special inventory items names
//EXT-5839
std::string server_name = name;
{
std::map<std::string, std::string>::const_iterator dictionary_iter;
for (dictionary_iter = LLLocalizedInventoryItemsDictionary::getInstance()->mInventoryItemsDict.begin();
dictionary_iter != LLLocalizedInventoryItemsDictionary::getInstance()->mInventoryItemsDict.end();
dictionary_iter++)
{
const std::string& localized_name = dictionary_iter->second;
if(localized_name == name)
{
server_name = dictionary_iter->first;
}
}
}
LLMessageSystem* msg = gMessageSystem; LLMessageSystem* msg = gMessageSystem;
msg->newMessageFast(_PREHASH_CreateInventoryItem); msg->newMessageFast(_PREHASH_CreateInventoryItem);
msg->nextBlock(_PREHASH_AgentData); msg->nextBlock(_PREHASH_AgentData);
...@@ -880,7 +945,7 @@ void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id, ...@@ -880,7 +945,7 @@ void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id,
msg->addS8Fast(_PREHASH_Type, (S8)asset_type); msg->addS8Fast(_PREHASH_Type, (S8)asset_type);
msg->addS8Fast(_PREHASH_InvType, (S8)inv_type); msg->addS8Fast(_PREHASH_InvType, (S8)inv_type);
msg->addU8Fast(_PREHASH_WearableType, (U8)wtype); msg->addU8Fast(_PREHASH_WearableType, (U8)wtype);
msg->addStringFast(_PREHASH_Name, name); msg->addStringFast(_PREHASH_Name, server_name);
msg->addStringFast(_PREHASH_Description, desc); msg->addStringFast(_PREHASH_Description, desc);
gAgent.sendReliableMessage(); gAgent.sendReliableMessage();
......
...@@ -235,9 +235,7 @@ LLWearable* LLWearableList::createNewWearable( EWearableType type ) ...@@ -235,9 +235,7 @@ LLWearable* LLWearableList::createNewWearable( EWearableType type )
LLWearable *wearable = generateNewWearable(); LLWearable *wearable = generateNewWearable();
wearable->setType( type ); wearable->setType( type );
LLSD item_name = LLSD().with("[WEARABLE_ITEM]", wearable->getTypeLabel()); std::string name = LLTrans::getString( LLWearableDictionary::getTypeDefaultNewName(wearable->getType()) );
std::string name = LLTrans::getString("NewWearable");
LLStringUtil::format(name, item_name);
wearable->setName( name ); wearable->setName( name );
LLPermissions perm; LLPermissions perm;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment