Merge branch 'deepl'

feature/prepare-cross-merge
Ulukyn 4 years ago committed by kaetemi
parent 0d57aad8b9
commit 3c178cb506
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -4577,17 +4577,20 @@ NLMISC_COMMAND (connectLangChannel, "Connect to lang channel", "<user id> <lang>
CPVPManager2 *inst = CPVPManager2::getInstance(); CPVPManager2 *inst = CPVPManager2::getInstance();
string action;
string lang = args[1]; string lang = args[1];
if (lang != "en" && lang != "fr" && lang != "de" && lang != "ru" && lang != "es" && lang != "rf" if (lang != "en" && lang != "fr" && lang != "de" && lang != "ru" && lang != "es" && lang != "rf" && !c->havePriv(":DEV:"))
&& lang != "rf-en" && lang != "rf-fr" && lang != "rf-de" && lang != "rf-ru" && lang != "rf-es")
return false; return false;
bool leave = !c->havePriv(":DEV:"); // Since June 2020, no any lang channels, players only can leave it bool leave = false;
if (args.size() > 2) if (args.size() > 2)
leave = args[2] == "1"; leave = args[2] == "1";
TChanID channel = inst->getFactionDynChannel(lang);
string channelName = lang;
// Convert langs to usr lang channels
if (lang == "en" || lang == "fr" || lang == "de" || lang == "ru" || lang == "es")
channelName = "usr_"+lang;
TChanID channel = inst->getFactionDynChannel(channelName);
if (channel != DYN_CHAT_INVALID_CHAN) if (channel != DYN_CHAT_INVALID_CHAN)
{ {

@ -436,7 +436,7 @@ static void prepareCharacterPositionForStore ( COfflineEntityState & state, cons
PROP(uint32,_GuildPoints)\ PROP(uint32,_GuildPoints)\
PROP(uint8,_TodayGuildPoints)\ PROP(uint8,_TodayGuildPoints)\
PROP_GAME_CYCLE_COMP(_NextTodayGuildPointsReset)\ PROP_GAME_CYCLE_COMP(_NextTodayGuildPointsReset)\
PROP2(_LangChannel,string,_LangChannel,_LangChannel="rf")\ PROP2(_LangChannel,string,_LangChannel,_LangChannel=val)\
PROP(uint32,_Organization)\ PROP(uint32,_Organization)\
PROP(uint32,_OrganizationStatus)\ PROP(uint32,_OrganizationStatus)\
PROP(uint32,_OrganizationPoints)\ PROP(uint32,_OrganizationPoints)\

@ -221,21 +221,22 @@ std::vector<TChanID> CPVPManager2::getCharacterChannels(CCharacter * user)
NLMISC::splitString(user->getLangChannel(), " ", langChannels); NLMISC::splitString(user->getLangChannel(), " ", langChannels);
for ( uint i = 0; i < langChannels.size(); i++ ) for ( uint i = 0; i < langChannels.size(); i++ )
{ {
TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find(langChannels[i]); if (langChannels[i] != "rf")
{
TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("usr_"+langChannels[i]);
if (it != _ExtraFactionChannel.end()) if (it != _ExtraFactionChannel.end())
{ {
result.push_back((*it).second); result.push_back((*it).second);
} }
} }
} }
else }
{
TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("en"); TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("rf");
if (it != _ExtraFactionChannel.end()) if (it != _ExtraFactionChannel.end())
{ {
result.push_back((*it).second); result.push_back((*it).second);
} }
}
PVP_CLAN::TPVPClan faction = user->getAllegiance().first; PVP_CLAN::TPVPClan faction = user->getAllegiance().first;
if( faction != PVP_CLAN::Neutral ) if( faction != PVP_CLAN::Neutral )
@ -1184,11 +1185,18 @@ void CPVPManager2::onIOSMirrorUp()
createExtraFactionChannel("de", true); createExtraFactionChannel("de", true);
createExtraFactionChannel("ru", true); createExtraFactionChannel("ru", true);
createExtraFactionChannel("es", true); createExtraFactionChannel("es", true);
createExtraFactionChannel("usr_en", true);
createExtraFactionChannel("usr_fr", true);
createExtraFactionChannel("usr_de", true);
createExtraFactionChannel("usr_ru", true);
createExtraFactionChannel("usr_es", true);
createExtraFactionChannel("rf", true); createExtraFactionChannel("rf", true);
createExtraFactionChannel("rf-fr", true); createExtraFactionChannel("rf-fr", true);
createExtraFactionChannel("rf-en", true); createExtraFactionChannel("rf-en", true);
createExtraFactionChannel("rf-es", true); createExtraFactionChannel("rf-es", true);
createExtraFactionChannel("rf-ed", true); createExtraFactionChannel("rf-de", true);
createExtraFactionChannel("rf-ru", true); createExtraFactionChannel("rf-ru", true);
#ifdef HAVE_MONGO #ifdef HAVE_MONGO

@ -512,13 +512,24 @@ void CChatClient::unsubscribeAllChatGroup()
//----------------------------------------------- //-----------------------------------------------
// disableTranslation // disableSendTranslation
//----------------------------------------------- //-----------------------------------------------
void CChatClient::disableTranslation( const string &lang ) void CChatClient::disableSendTranslation( const string &lang )
{ {
if (find(_DontTranslate.begin(), _DontTranslate.end(), lang) == _DontTranslate.end()) if (find(_DontSendTranslation.begin(), _DontSendTranslation.end(), lang) == _DontSendTranslation.end())
{ {
_DontTranslate.push_back(lang); _DontSendTranslation.push_back(lang);
}
}
//-----------------------------------------------
// disableReceiveTranslation
//-----------------------------------------------
void CChatClient::disableReceiveTranslation( const string &lang )
{
if (find(_DontReceiveTranslation.begin(), _DontReceiveTranslation.end(), lang) == _DontReceiveTranslation.end())
{
_DontReceiveTranslation.push_back(lang);
} }
} }
@ -527,16 +538,25 @@ void CChatClient::disableTranslation( const string &lang )
//----------------------------------------------- //-----------------------------------------------
void CChatClient::resetDisabledTranslations() void CChatClient::resetDisabledTranslations()
{ {
_DontTranslate.clear(); _DontReceiveTranslation.clear();
_DontSendTranslation.clear();
} }
//----------------------------------------------- //-----------------------------------------------
// haveDisabledTranslation // dontReceiveTranslation
//----------------------------------------------- //-----------------------------------------------
bool CChatClient::haveDisabledTranslation( const string &lang ) bool CChatClient::dontReceiveTranslation( const string &lang )
{ {
return find(_DontTranslate.begin(), _DontTranslate.end(), lang) != _DontTranslate.end(); return find(_DontReceiveTranslation.begin(), _DontReceiveTranslation.end(), lang) != _DontReceiveTranslation.end();
} }
//-----------------------------------------------
// dontSendTranslation
//-----------------------------------------------
bool CChatClient::dontSendTranslation( const string &lang )
{
return find(_DontSendTranslation.begin(), _DontSendTranslation.end(), lang) != _DontSendTranslation.end();
}

@ -206,9 +206,11 @@ public :
// unsubscribe to all chat group // unsubscribe to all chat group
void unsubscribeAllChatGroup(); void unsubscribeAllChatGroup();
void disableTranslation( const std::string &lang ); void disableSendTranslation( const std::string &lang );
void disableReceiveTranslation( const std::string &lang );
void resetDisabledTranslations(); void resetDisabledTranslations();
bool haveDisabledTranslation( const std::string &lang ); bool dontReceiveTranslation( const std::string &lang );
bool dontSendTranslation( const std::string &lang );
private : private :
@ -275,7 +277,8 @@ private :
/// keep infos about which string has been received by the client /// keep infos about which string has been received by the client
std::vector<bool> _KnownStrings; std::vector<bool> _KnownStrings;
std::vector<std::string> _DontTranslate; std::vector<std::string> _DontReceiveTranslation;
std::vector<std::string> _DontSendTranslation;
/** /**
* Update the audience of this client * Update the audience of this client

@ -552,6 +552,9 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
TClientInfoCont::iterator itCl = _Clients.find( sender ); TClientInfoCont::iterator itCl = _Clients.find( sender );
if( itCl != _Clients.end() ) if( itCl != _Clients.end() )
{ {
CChatManager &cm = IOS->getChatManager();
CChatClient &senderClient = cm.getClient(sender);
// if( itCl->second->isMuted() ) // if( itCl->second->isMuted() )
CEntityId eid = TheDataset.getEntityId(sender); CEntityId eid = TheDataset.getEntityId(sender);
if(_MutedUsers.find( eid ) != _MutedUsers.end()) if(_MutedUsers.find( eid ) != _MutedUsers.end())
@ -603,6 +606,8 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
// clean up container // clean up container
_DestUsers.clear(); _DestUsers.clear();
string senderLang = SM->getLanguageCodeString(ci->Language);
switch( itCl->second->getChatMode() ) switch( itCl->second->getChatMode() )
{ {
// dynamic group // dynamic group
@ -617,8 +622,6 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
bool have_es = false; bool have_es = false;
CChatGroup::TMemberCont::iterator itA; CChatGroup::TMemberCont::iterator itA;
string sender_lang = SM->getLanguageCodeString(ci->Language);
for( itA = itCl->second->getAudience().Members.begin(); for( itA = itCl->second->getAudience().Members.begin();
itA != itCl->second->getAudience().Members.end(); itA != itCl->second->getAudience().Members.end();
++itA ) ++itA )
@ -639,16 +642,12 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
receiver_lang = SM->getLanguageCodeString(co->Language); receiver_lang = SM->getLanguageCodeString(co->Language);
} }
if (EnableDeepL) if (EnableDeepL && !senderClient.dontSendTranslation(senderLang))
{ {
CChatClient &client = getClient(*itA); CChatClient &client = getClient(*itA);
if (sender_lang == "wk") if (senderLang == "wk")
receiver_lang = sender_lang; receiver_lang = senderLang;
if (ucstr[0] != '>' && client.haveDisabledTranslation(sender_lang))
receiver_lang = sender_lang;
if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code
{ {
@ -656,7 +655,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
{ {
string usedlang = ucstr.toString().substr(2, 2); string usedlang = ucstr.toString().substr(2, 2);
//nlinfo("used: %s, user: %s", usedlang.c_str(), receiver_lang.c_str()); //nlinfo("used: %s, user: %s", usedlang.c_str(), receiver_lang.c_str());
if (usedlang == receiver_lang && !client.haveDisabledTranslation(sender_lang)) if (usedlang == receiver_lang && !client.dontReceiveTranslation(usedlang))
sendChat( itCl->second->getChatMode(), *itA, ucstr.substr(5), sender ); sendChat( itCl->second->getChatMode(), *itA, ucstr.substr(5), sender );
} }
else else
@ -664,7 +663,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
sendChat( itCl->second->getChatMode(), *itA, ucstr.substr(1), sender ); sendChat( itCl->second->getChatMode(), *itA, ucstr.substr(1), sender );
} }
} }
else if (sender_lang == receiver_lang) // Sent directly if sender and receiver uses same lang else if (senderLang == receiver_lang || client.dontReceiveTranslation(senderLang)) // Sent directly if sender and receiver uses same lang
{ {
sendChat( itCl->second->getChatMode(), *itA, ucstr, sender ); sendChat( itCl->second->getChatMode(), *itA, ucstr, sender );
} }
@ -687,7 +686,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
sendChat( itCl->second->getChatMode(), *itA, ucstr, sender ); sendChat( itCl->second->getChatMode(), *itA, ucstr, sender );
} }
string langs = sender_lang; string langs = senderLang;
if (have_fr) if (have_fr)
langs += "-fr"; langs += "-fr";
if (have_de) if (have_de)
@ -716,11 +715,12 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
if (EnableDeepL) if (EnableDeepL)
{ {
string sender_lang = SM->getLanguageCodeString(ci->Language);
if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code
chatInGroup( grpId, ucstr.substr(1), sender ); chatInGroup( grpId, ucstr.substr(1), sender );
else if (senderClient.dontSendTranslation(senderLang))
chatInGroup( grpId, ucstr, sender );
else else
_Log.displayNL("region:%s|%s|*|%s-*|%s", grpId.toString().c_str(), fullName.c_str(), sender_lang.c_str(), ucstr.toString().c_str() ); _Log.displayNL("region:%s|%s|*|%s-*|%s", grpId.toString().c_str(), fullName.c_str(), senderLang.c_str(), ucstr.toUtf8().c_str() );
} }
else else
chatInGroup( grpId, ucstr, sender ); chatInGroup( grpId, ucstr, sender );
@ -761,14 +761,16 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
bool sendToMongo = true; bool sendToMongo = true;
bool sendToAllUni = false; bool sendToAllUni = false;
string autosub = "1"; string autoSub = "1";
uint8 startPos = 0; uint8 startPos = 0;
string mongoText = ucstr.toUtf8(); string mongoText = ucstr.toUtf8();
string chatId = "all"; string chatId = "all";
string chatType = "univers"; string chatType = "univers";
string usedlang = SM->getLanguageCodeString(ci->Language);
if (EnableDeepL)
string usedlang = senderLang;
if (EnableDeepL && !senderClient.dontSendTranslation(senderLang))
{ {
chatType = "dynamic"; chatType = "dynamic";
if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code
@ -788,7 +790,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
source_lang = mongoText.substr(6, 2); source_lang = mongoText.substr(6, 2);
string sourceText = mongoText.substr(9, endOfOriginal-9); string sourceText = mongoText.substr(9, endOfOriginal-9);
strFindReplace(sourceText, ")", "}"); strFindReplace(sourceText, ")", "}");
mongoText = "["+source_lang+"](http://chatdev.ryzom.com/channel/pub-universe-"+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4); mongoText = "["+source_lang+"](http://chat.ryzom.com/channel/pub-universe-"+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
} }
else else
{ {
@ -796,14 +798,14 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
mongoText = mongoText.substr(4, mongoText.size()-4); mongoText = mongoText.substr(4, mongoText.size()-4);
} }
if (source_lang == "en") // in RC the icon are :us: if (source_lang == "en") // in RC the icon are :gb:
mongoText = ":us:"+mongoText; mongoText = ":gb:"+mongoText;
else else
mongoText = ":"+source_lang+":"+mongoText; mongoText = ":"+source_lang+":"+mongoText;
chatId = "FACTION_"+toUpper(usedlang); chatId = "FACTION_"+toUpper(usedlang);
if (usedlang != SM->getLanguageCodeString(ci->Language)) if (usedlang != SM->getLanguageCodeString(ci->Language))
autosub = "0"; autoSub = "0";
} }
else else
@ -813,8 +815,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
} }
else else
{ {
string sender_lang = SM->getLanguageCodeString(ci->Language); _Log.displayNL("%s|%s|*|%s-*|%s", "universe", fullName.c_str(), senderLang.c_str(), ucstr.toUtf8().c_str());
_Log.displayNL("%s|%s|*|%s-*|%s", "universe", fullName.c_str(), sender_lang.c_str(), ucstr.toUtf8().c_str());
sendToMongo = false; sendToMongo = false;
} }
} }
@ -826,15 +827,14 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
{ {
if (sendToAllUni) if (sendToAllUni)
{ {
string userlang = SM->getLanguageCodeString(ci->Language); CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_EN', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, senderLang == "en"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_EN', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, userlang == "en"?"1":"0")); CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_DE', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, senderLang == "de"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_DE', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, userlang == "de"?"1":"0")); CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_ES', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, senderLang == "es"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_ES', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, userlang == "es"?"1":"0")); CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_FR', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, senderLang == "fr"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_FR', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, userlang == "fr"?"1":"0")); CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_RU', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, senderLang == "ru"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': 'FACTION_RU', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), date, userlang == "ru"?"1":"0"));
} }
else else
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': '%s', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), chatId.c_str(), date, autosub.c_str())); CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': '%s', 'chatId': '%s', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatType.c_str(), chatId.c_str(), date, autoSub.c_str()));
} }
#endif #endif
@ -866,7 +866,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
double date = 1000.0*(double)CTime::getSecondsSince1970(); double date = 1000.0*(double)CTime::getSecondsSince1970();
#ifdef HAVE_MONGO #ifdef HAVE_MONGO
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'guildId', 'chatId': '%s', 'date': %f, 'ig': true, 'autosub': 1 }", CMongo::quote(fullName).c_str(), CMongo::quote(ucstr.toUtf8()).c_str(), sGuildId.str().c_str(), date)); CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'guildId', 'chatId': '%s', 'date': %f, 'ig': true, 'autoSub': 1 }", CMongo::quote(fullName).c_str(), CMongo::quote(ucstr.toUtf8()).c_str(), sGuildId.str().c_str(), date));
#endif #endif
chatInGroup( grpId, ucstr, sender ); chatInGroup( grpId, ucstr, sender );
} }
@ -899,17 +899,25 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
double date = 1000.0*(double)CTime::getSecondsSince1970(); double date = 1000.0*(double)CTime::getSecondsSince1970();
bool sendToMongo = true;
string mongoText = ucstr.toUtf8();
bool sendMessages = true;
bool sendToAllForge = false; bool sendToAllForge = false;
bool haveOriginMessage = false;
uint8 startPos = 0; uint8 startPos = 0;
string mongoText = ucstr.toUtf8(); string originLang = senderLang;
string usedlang = ""; string translatedLang = "";
string autosub = "0"; string autoSub = "0";
if (EnableDeepL) if (EnableDeepL)
{ {
if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code if (senderClient.dontSendTranslation(senderLang))
{
sendToAllForge = true;
}
else if (ucstr[0] == '>') // Sent directly when prefixed by '>', it's the anti-translation code
{ {
startPos = 1; startPos = 1;
mongoText = mongoText.substr(1); mongoText = mongoText.substr(1);
@ -917,63 +925,67 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
if (mongoText.size() > 4 && mongoText[0] == ':' && mongoText[3] == ':') if (mongoText.size() > 4 && mongoText[0] == ':' && mongoText[3] == ':')
{ {
startPos = 5; startPos = 5;
usedlang = mongoText.substr(1, 2); translatedLang = mongoText.substr(1, 2);
string source_lang = usedlang;
if (endOfOriginal != string::npos) if (endOfOriginal != string::npos)
{ {
haveOriginMessage = true;
if (mongoText.size() > 9) if (mongoText.size() > 9)
source_lang = mongoText.substr(6, 2); originLang = mongoText.substr(6, 2);
string sourceText = mongoText.substr(9, endOfOriginal-9); string originText = mongoText.substr(9, endOfOriginal-9);
strFindReplace(sourceText, ")", "}"); strFindReplace(originText, ")", "}");
mongoText = "["+source_lang+"](http://chatdev.ryzom.com/channel/pub-forge-"+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4); mongoText = "["+originLang+"](http://chat.ryzom.com/channel/pub-forge-"+originLang+"? "+originText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
} }
else else
{ {
usedlang = mongoText.substr(1, 2); originLang = translatedLang;
mongoText = mongoText.substr(4, mongoText.size()-4); mongoText = mongoText.substr(4, mongoText.size()-4);
} }
if (source_lang == "en") // in RC the icon are :us: if (originLang == "en") // in RC the icon are :gb:
mongoText = ":us:"+mongoText; mongoText = ":gb:"+mongoText;
else else
mongoText = ":"+source_lang+":"+mongoText; mongoText = ":"+originLang+":"+mongoText;
} }
else if (chatId == "FACTION_RF") else if (chatId == "FACTION_RF") // Only when it's a not translated text
sendToAllForge = true; sendToAllForge = true;
} }
// Send for translation
else if (chatId == "FACTION_RF" || chatId == "FACTION_EN" || chatId == "FACTION_DE" || chatId == "FACTION_FR" || chatId == "FACTION_ES" || chatId == "FACTION_RU") else if (chatId == "FACTION_RF" || chatId == "FACTION_EN" || chatId == "FACTION_DE" || chatId == "FACTION_FR" || chatId == "FACTION_ES" || chatId == "FACTION_RU")
{ {
usedlang = SM->getLanguageCodeString(ci->Language); _Log.displayNL("%s|%s|*|%s-*|%s", string("#"+chatId).c_str(), fullName.c_str(), senderLang.c_str(), ucstr.toUtf8().c_str());
_Log.displayNL("%s|%s|*|%s-*|%s", string("#"+chatId).c_str(), fullName.c_str(), usedlang.c_str(), ucstr.toUtf8().c_str()); sendMessages = false; // We need translated it before
sendToMongo = false;
} }
} }
#ifdef HAVE_MONGO if (sendMessages) // only send to mongo if it's not a message to translate
if (sendToMongo) // only send to mongo if it's not a translated message
{ {
string userlang = SM->getLanguageCodeString(ci->Language); #ifdef HAVE_MONGO
if (sendToAllForge) if (sendToAllForge)
{ {
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-EN', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, userlang == "en"?"1":"0")); CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-EN', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, senderLang == "en"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-DE', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, userlang == "de"?"1":"0")); CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-DE', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, senderLang == "de"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-ES', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, userlang == "es"?"1":"0")); CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-ES', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, senderLang == "es"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-FR', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, userlang == "fr"?"1":"0")); CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-FR', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, senderLang == "fr"?"1":"0"));
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-RU', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, userlang == "ru"?"1":"0")); CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': 'FACTION_RF-RU', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), date, senderLang == "ru"?"1":"0"));
} }
else else
{ {
if (chatId == "FACTION_RF") if (chatId == "FACTION_RF")
chatId = "FACTION_RF-"+toUpper(usedlang); {
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': '%s', 'date': %f, 'ig': true, 'autosub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatId.c_str(), date, userlang == usedlang?"1":"0")); if (translatedLang.empty())
chatId = "FACTION_RF-"+toUpper(senderLang);
else
chatId = "FACTION_RF-"+toUpper(translatedLang);
} }
CMongo::insert("ryzom_chats", toString("{ 'username': '%s', 'chat': '%s', 'chatType': 'dynamic', 'chatId': '%s', 'date': %f, 'ig': true, 'autoSub': %s }", CMongo::quote(fullName).c_str(), CMongo::quote(mongoText).c_str(), chatId.c_str(), date, (translatedLang.empty() || translatedLang == senderLang)?"1":"0"));
} }
#endif #endif
if (!session->getChan()->getDontBroadcastPlayerInputs() && startPos != 0) if (!session->getChan()->getDontBroadcastPlayerInputs())
{ {
// add msg to the historic // add msg to the historic
CDynChatChan::CHistoricEntry entry; CDynChatChan::CHistoricEntry entry;
@ -1005,14 +1017,28 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
} }
} }
// broadcast to other client in the channel // broadcast to other client in the channel
CDynChatSession *dcc = session->getChan()->getFirstSession(); CDynChatSession *dcc = session->getChan()->getFirstSession();
while (dcc) while (dcc)
{ {
NLMISC::CEntityId receiverId = TheDataset.getEntityId(dcc->getClient()->getID()); NLMISC::CEntityId receiverId = TheDataset.getEntityId(dcc->getClient()->getID());
CCharacterInfos* co = IOS->getCharInfos(receiverId); CCharacterInfos* co = IOS->getCharInfos(receiverId);
if (!EnableDeepL || usedlang.empty() || usedlang == SM->getLanguageCodeString(co->Language)) CChatClient &receiverClient = getClient(dcc->getClient()->getID());
bool canSendChat = true;
if (EnableDeepL)
{
if (receiverClient.dontReceiveTranslation(originLang))
{
if (haveOriginMessage) // Only send untranslated message
canSendChat = false;
}
else if (!translatedLang.empty() && translatedLang != SM->getLanguageCodeString(co->Language))
canSendChat = false;
}
if (canSendChat)
sendChat(itCl->second->getChatMode(), dcc->getClient()->getID(), content.substr(startPos), sender, chanId); sendChat(itCl->second->getChatMode(), dcc->getClient()->getID(), content.substr(startPos), sender, chanId);
dcc = dcc->getNextChannelSession(); // next session in this channel dcc = dcc->getNextChannelSession(); // next session in this channel
} }
@ -1020,7 +1046,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
else else
{ {
// only send an echo to the sender // only send an echo to the sender
if (!EnableDeepL || usedlang.empty()) // only send an echo to the sender if (!EnableDeepL) // only send an echo to the sender
sendChat(itCl->second->getChatMode(), itCl->first, ucstr, sender, chanId); sendChat(itCl->second->getChatMode(), itCl->first, ucstr, sender, chanId);
} }
@ -1039,6 +1065,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
CUnifiedNetwork::getInstance()->send(serviceId, msgout); CUnifiedNetwork::getInstance()->send(serviceId, msgout);
} }
if (session->getChan()->getUnifiedChannel()) if (session->getChan()->getUnifiedChannel())
{ {
// send the text to other shards // send the text to other shards
@ -1048,6 +1075,7 @@ void CChatManager::chat( const TDataSetRow& sender, const ucstring& ucstr )
} }
} }
} }
}
break; break;
// static group // static group
@ -1098,13 +1126,22 @@ void CChatManager::chatInGroup( TGroupId& grpId, const ucstring& ucstr, const TD
list<CEntityId> logDest; list<CEntityId> logDest;
uint8 startPos = 0; uint8 startPos = 0;
string usedlang; string usedlang = "";
if (EnableDeepL && ucstr.length() > 4 && ucstr[0] == ':' && ucstr[3] == ':') // check lang prefix string str = ucstr.toString();
if (EnableDeepL && str.length() > 4 && str[0] == ':' && str[3] == ':') // check lang prefix
{ {
usedlang = ucstr.toString().substr(1, 2); usedlang = str.substr(1, 2);
startPos = 4; startPos = 4;
} }
bool areOriginal = true;
string originLang = usedlang;
if (EnableDeepL && str.length() > 8 && str[4] == '{' && str[5] == ':' && str[8] == ':') // check lang origin
{
areOriginal = false;
originLang = str.substr(6, 2);
}
for( itM = chatGrp.Members.begin(); itM != chatGrp.Members.end(); ++itM ) for( itM = chatGrp.Members.begin(); itM != chatGrp.Members.end(); ++itM )
{ {
CMirrorPropValueRO<uint32> instanceId( TheDataset, *itM, DSPropertyAI_INSTANCE ); CMirrorPropValueRO<uint32> instanceId( TheDataset, *itM, DSPropertyAI_INSTANCE );
@ -1113,7 +1150,14 @@ void CChatManager::chatInGroup( TGroupId& grpId, const ucstring& ucstr, const TD
{ {
NLMISC::CEntityId receiverId = TheDataset.getEntityId(*itM); NLMISC::CEntityId receiverId = TheDataset.getEntityId(*itM);
CCharacterInfos* co = IOS->getCharInfos(receiverId); CCharacterInfos* co = IOS->getCharInfos(receiverId);
if (usedlang != SM->getLanguageCodeString(co->Language)) CChatClient &client = getClient(*itM);
if (client.dontReceiveTranslation(originLang))
{
if (!areOriginal)
continue;
}
else if (usedlang != SM->getLanguageCodeString(co->Language))
continue; continue;
} }
@ -1907,7 +1951,7 @@ void CChatManager::sendFarChat(const string &name, const ucstring& ucstr, const
source_lang = mongoText.substr(6, 2); source_lang = mongoText.substr(6, 2);
string sourceText = mongoText.substr(9, endOfOriginal-9); string sourceText = mongoText.substr(9, endOfOriginal-9);
strFindReplace(sourceText, ")", "}"); strFindReplace(sourceText, ")", "}");
mongoText = "["+source_lang+"](http://chatdev.ryzom.com/channel/"+rc_channel+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4); mongoText = "["+source_lang+"](http://chat.ryzom.com/channel/"+rc_channel+source_lang+"? "+sourceText+") "+mongoText.substr(endOfOriginal+4, mongoText.size()-endOfOriginal-4);
} }
else else
{ {
@ -1916,8 +1960,8 @@ void CChatManager::sendFarChat(const string &name, const ucstring& ucstr, const
} }
if (source_lang == "en") // in RC the icon are :us: if (source_lang == "en") // in RC the icon are :gb:
mongoText = ":us:"+mongoText; mongoText = ":gb:"+mongoText;
else else
mongoText = ":"+source_lang+":"+mongoText; mongoText = ":"+source_lang+":"+mongoText;

@ -2019,12 +2019,19 @@ void cbUserDontTranslateLanguages( CMessage& msgin, const string &serviceName, T
CChatClient &client = cm.getClient(player); CChatClient &client = cm.getClient(player);
nlinfo("USER DISBALED TRANSLATIONS: %s", langs.c_str());
vector<string> vlangs; vector<string> vlangs;
NLMISC::splitString(langs, "|", vlangs); NLMISC::splitString(langs, "|", vlangs);
client.resetDisabledTranslations(); client.resetDisabledTranslations();
for (uint i=0; i<vlangs.size(); i++) for (uint i=0; i<vlangs.size(); i++)
{ {
client.disableTranslation(vlangs[i]); if (vlangs[i].size() == 3)
{
if (vlangs[i][0] == '>')
client.disableSendTranslation(vlangs[i].substr(1));
else if (vlangs[i][0] == '<')
client.disableReceiveTranslation(vlangs[i].substr(1));
}
} }
} }

Loading…
Cancel
Save