EXT-8400 FIXED Updated default inventory item names ("New Script", etc) on viewer language switch.

Bug reason
==========

New inventory items get names like "New Script", "New Undershirt" etc., but the names are translated on-the-fly (see EXT-5839), so the user actually sees "Nouveau script", "Nouveau débardeur" etc., respectively.
However when the user changes viewer language, the old localized names still exist in the inventory cache, so, for example, if you create an undershirt in French and then switch to Enlgish, the undershirt will be named "Nouveau d bardeur", which is the old cached localized name with non-ASCII characters replaced with spaces.

Fix
===

To get rid of obsolete translations I clear all caches whenever viewer language gets changed.

Other changes
=============

- Added a check for agent region being NULL to LLAgentLanguage::update().
- Removed LLAgentLanguage constructor and base classes because it's never instantiated.

Reviewed by Seraph at https://codereview.productengine.com/secondlife/r/744/

--HG--
branch : product-engine
master
Vadim Savchuk 2010-07-14 18:18:47 +03:00
parent 706e75dff3
commit 223b25de0d
3 changed files with 28 additions and 11 deletions

View File

@ -39,21 +39,35 @@
// library includes
#include "llui.h" // getLanguage()
LLAgentLanguage::LLAgentLanguage()
// static
void LLAgentLanguage::init()
{
gSavedSettings.getControl("Language")->getSignal()->connect(boost::bind(&update));
gSavedSettings.getControl("InstallLanguage")->getSignal()->connect(boost::bind(&update));
gSavedSettings.getControl("SystemLanguage")->getSignal()->connect(boost::bind(&update));
gSavedSettings.getControl("LanguageIsPublic")->getSignal()->connect(boost::bind(&update));
gSavedSettings.getControl("Language")->getSignal()->connect(boost::bind(&onChange));
gSavedSettings.getControl("InstallLanguage")->getSignal()->connect(boost::bind(&onChange));
gSavedSettings.getControl("SystemLanguage")->getSignal()->connect(boost::bind(&onChange));
gSavedSettings.getControl("LanguageIsPublic")->getSignal()->connect(boost::bind(&onChange));
}
// static
void LLAgentLanguage::onChange()
{
// Clear inventory cache so that default names of inventory items
// appear retranslated (EXT-8308).
gSavedSettings.setBOOL("PurgeCacheOnNextStartup", TRUE);
}
// send language settings to the sim
// static
bool LLAgentLanguage::update()
{
LLSD body;
std::string url = gAgent.getRegion()->getCapability("UpdateAgentLanguage");
std::string url;
if (gAgent.getRegion())
{
url = gAgent.getRegion()->getCapability("UpdateAgentLanguage");
}
if (!url.empty())
{
std::string language = LLUI::getLanguage();

View File

@ -33,14 +33,14 @@
#ifndef LL_LLAGENTLANGUAGE_H
#define LL_LLAGENTLANGUAGE_H
#include "llsingleton.h" // LLSingleton<>
#include "llevent.h"
class LLAgentLanguage: public LLSingleton<LLAgentLanguage>, public LLOldEvents::LLSimpleListener
class LLAgentLanguage
{
public:
LLAgentLanguage();
static void init();
static bool update();
private:
static void onChange();
};
#endif // LL_LLAGENTLANGUAGE_H

View File

@ -45,6 +45,7 @@
#include "llgroupmgr.h"
#include "llagent.h"
#include "llagentcamera.h"
#include "llagentlanguage.h"
#include "llagentwearables.h"
#include "llwindow.h"
#include "llviewerstats.h"
@ -946,6 +947,8 @@ bool LLAppViewer::init()
LLStringOps::sPM = LLTrans::getString("dateTimePM");
}
LLAgentLanguage::init();
return true;
}