Page 1 of 1

Notification log translations are in opponent's language

Posted: 06 October 2021, 03:47
by QWERTY_Already_Taken
Hi! I'm a developer here. I've tried different things including the right way of translating log texts, but I was informed that the log texts are translated in the active player's language. I even got an image from a player and it doesn't make sense to me.

Player's image:
(The player put the arrows and labels on the image, but it seems there are different languages up there based on who is the active player)
Image

Here is one section of the offending code:

from material.inc.php

Code: Select all

$this->slots = array(
   "1x1" => self::_("left-high-post"),
   "1x2" => self::_("left-high"),
   ...
);
from penaltychallenge.game.php

Code: Select all

$slot_name = $this->slots[$slot_n];
self::notifyAllPlayers( 'shooter_aim', clienttranslate( 'The shooter aims for <b>${slot_name}<b>' ), array(
   'slot_name' => $slot_name
) );
I would be really grateful if someone can help me and tell me what I did wrong.

Re: Notification log translations are in opponent's language

Posted: 06 October 2021, 05:22
by ufm
This question should be posted on developer category: viewforum.php?f=12

Re: Notification log translations are in opponent's language

Posted: 06 October 2021, 07:25
by robinzig
Definitely should be in the developer forum, but since I'm here and the solution is obvious / simple:

Your material.inc.php needs to use clienttranslate rather than self::_ for anything that might get sent to the client side.

Re: Notification log translations are in opponent's language

Posted: 06 October 2021, 09:00
by Een
I have moved this topic to the developer forum.

In addition to robinzig's answer, please note that you'll need to list substituted clientranslate strings in the "i18n" parameter array of your notifications for translation to apply.

Re: Notification log translations are in opponent's language

Posted: 06 October 2021, 19:08
by QWERTY_Already_Taken
Thank you all! I'll try it out. Sorry I posted this in the wrong place