Make client-aware translation handling more coherent

I have no clear idea why this was still using translateString(), since it's entirely unnecessary when we aren't selectively translating.
This commit is contained in:
Dylan K. Taylor
2023-01-08 16:45:57 +00:00
parent 1c96e7936c
commit 4a3d9f8f83
2 changed files with 4 additions and 5 deletions

View File

@ -935,11 +935,11 @@ class NetworkSession{
if($message instanceof Translatable){
//we can't send nested translations to the client, so make sure they are always pre-translated by the server
$language = $this->player->getLanguage();
$parameters = array_map(fn(string|Translatable $p) => $p instanceof Translatable ? $language->translate($p) : $p, $message->getParameters());
if(!$this->server->isLanguageForced()){
$parameters = array_map(fn(string|Translatable $p) => $p instanceof Translatable ? $language->translate($p) : $p, $message->getParameters());
$this->sendDataPacket(TextPacket::translation($language->translateString($message->getText(), $parameters, "pocketmine."), $parameters));
}else{
$this->sendDataPacket(TextPacket::raw($language->translateString($message->getText(), $parameters)));
$this->sendDataPacket(TextPacket::raw($language->translate($message)));
}
}else{
$this->sendDataPacket(TextPacket::raw($message));