Changed: First try to add translation tags into Bot names and Titles (will help rename of player to be translated and events npcs)

--HG--
branch : patches-from-atys
hg/hotfix/patches-from-atys
ulukyn@gmail.com 7 years ago
parent f17aeff6f2
commit 99a949b889

@ -2296,7 +2296,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value)
if (pos != ucstring::npos)
{
ucstring sn = replacement;
_EntityName = sn.substr(0, pos);
_EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(sn.substr(0, pos));
ucstring::size_type pos2 = sn.find('$', pos + 1);
_TitleRaw = sn.substr(pos+1, pos2 - pos - 1);
replacement = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(_TitleRaw, womanTitle);
@ -2309,7 +2309,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value)
{
// build the final name
p1 = _EntityName.find('$');
_EntityName = _EntityName.substr(0, p1); // + _Name.substr(p2+1)
_EntityName = STRING_MANAGER::CStringManagerClient::getLocalizedName(_EntityName.substr(0, p1)); // + _Name.substr(p2+1)
// Get extended name
_NameEx = replacement;
newtitle = _NameEx;

@ -1411,8 +1411,7 @@ const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bo
if (label[0] == '#')
{
static ucstring rawString;
rawString = label.substr(1, label.size()-1);
return rawString.c_str();
return getLocalizedName(label.substr(1, label.size()-1));
}
// avoid case problems
@ -1615,14 +1614,41 @@ const ucchar *CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CShee
const ucchar *CStringManagerClient::getTitleLocalizedName(const ucstring &titleId, bool women)
{
vector<ucstring> listInfos = getTitleInfos(titleId, women);
if (!listInfos.empty())
{
_TitleWords.push_back(listInfos[0]);
return _TitleWords.back().c_str();
return getLocalizedName(_TitleWords.back());
}
return titleId.c_str();
return getLocalizedName(titleId);
}
const ucchar *CStringManagerClient::getLocalizedName(const ucstring &text)
{
if (text[0] == '%')
{
vector<ucstring> textLocalizations;
ucstring defaultText = ucstring("");
splitUCString(text.substr(1), ucstring("["), textLocalizations);
if (!textLocalizations.empty())
{
for(uint i = 0; i<textLocalizations.size(); i++)
{
if (textLocalizations[i].substr(0, 3) == ucstring(CI18N::getCurrentLanguageCode()+"]"))
{
return textLocalizations[i].substr(3).c_str();
}
else if (textLocalizations[i].substr(0, 3) == ucstring("wk]"))
{
defaultText = textLocalizations[i].substr(3).c_str();
}
}
}
if (!defaultText.empty()) {
return defaultText.c_str();
}
}
return text.c_str();
}
// ***************************************************************************

@ -107,6 +107,7 @@ public:
// Get the Localized Title name
static const ucchar *getTitleLocalizedName(const ucstring &titleId, bool women);
static const ucchar *getLocalizedName(const ucstring &text);
static std::vector<ucstring> getTitleInfos(const ucstring &titleId, bool women);
// Get the Localized name of a classification type

Loading…
Cancel
Save