self::_(...) doesn't work with some strings
Posted: 20 June 2021, 15:04
Has anyone experienced anything like this: I had reports that some BgaUserException messages are not going back to the clients translated, so started methodically experimenting and discovered that in my X.game.php, self::_(...) simply does not translate some strings.
This is best explained with some code that reproduces the problem:
These are various strings used throughout the game. All of them have been translated into French (amongst other languages) at translatehq, yet when I run the game with French as the language and trigger the above code, I see:
So, 4 out of the 6 are displaying the French but (the middle) 2 are not, even though the translations exist in all cases. For example:

It's completely consistent: some of the strings always return the translated version through self::_(...), and others never do.
Does anyone have the slightest clue or experience as to what could be causing a different result for different strings even within the same block of code?
To head off the first and obvious question of "do your strings match the translation sources perfectly?" the answer is: I've checked that dozens of times, but more importantly if they weren't then these near duplicates would have turned up as separate strings in the translation system, which they haven't.
Is there anything potentially obvious I'm missing?
This is best explained with some code that reproduces the problem:
Code: Select all
echo("<div>");
echo(self::_("My play area"));
echo("</div>");
echo("<div>");
echo(self::_("Available Drivers"));
echo("</div>");
echo("<div>");
echo(self::_("There are no white spaces available to move into"));
echo("</div>");
echo("<div>");
echo(self::_("Empty"));
echo("</div>");
echo("<div>");
echo(self::_("Car Chief"));
echo("</div>");
echo("<div>");
echo(self::_("Surprise me!"));
echo("</div>");
Code: Select all
Ma zone de jeu
Pilotes Disponibles
There are no white spaces available to move into
Empty
Chef de Voiture
Surprenez-moi !
It's completely consistent: some of the strings always return the translated version through self::_(...), and others never do.
Does anyone have the slightest clue or experience as to what could be causing a different result for different strings even within the same block of code?
To head off the first and obvious question of "do your strings match the translation sources perfectly?" the answer is: I've checked that dozens of times, but more importantly if they weren't then these near duplicates would have turned up as separate strings in the translation system, which they haven't.
Is there anything potentially obvious I'm missing?