Problems with translation in notif logs with arguments
Posted: 02 January 2018, 16:57
Hello,
I have troubles with translation inside the log, when the message is passed through a notification (notif_msg parameter). Enclosed arguments are not translated, even if all litteral strings are enclosed with clienttranslate().
Here's the simplest example of a string with argument that won't translate:
The method getColoredText is defined like this:
Here, all the string will appear translated in play, except the You that will remain You. This You is referenced in the translation string so the community could propose a translation for it.
Here the part of the string is passed to a function to be colored but there are other situations where these won't translate as well (a function to convert a code to the corresponding text, another to convert a number to its spelling, etc.).
Do you have any idea what I do wrong?
Thanks!
Tcheby
I have troubles with translation inside the log, when the message is passed through a notification (notif_msg parameter). Enclosed arguments are not translated, even if all litteral strings are enclosed with clienttranslate().
Here's the simplest example of a string with argument that won't translate:
Code: Select all
self::notifyPlayer($player_id, 'log', clienttranslate('${You} have ${ressource_count} ${icon}.'), array(
'You' => self::getColoredText(clienttranslate('You'), $player_id), /* 'You' word won't translate */
'ressource_count' => $ressource_count, /* just a number */
'icon' => $icon /* just a span with a background-image */
));Code: Select all
function getColoredText($text, $player_id) {
$color = self::getPlayerColorFromId($player_id);
return "<span style='font-weight: bold; color:#".$color.";'>".$text."</span>";
}Here the part of the string is passed to a function to be colored but there are other situations where these won't translate as well (a function to convert a code to the corresponding text, another to convert a number to its spelling, etc.).
Do you have any idea what I do wrong?
Thanks!
Tcheby