How to Mark Dynamic Description for Translation
Posted: 30 August 2021, 16:39
Hi,
I have developed a game called Zener and I am trying to resolve a translation bug where the names of the pieces aren't translated in the description from states.inc.php.
I have this in states.inc.php:
inside of zener.game.php, I have tried a few things that the forums seemed to suggest would work:
Neither of these have solved the issue, the strings still show as "<Translated text> the circle". From the forums, I have understood that translating substitutions does not work, hence trying adding the full strings (though keeping the actplayer/you substitutions), in the hopes those could then be translated, but I am still not seeing them translated. Can anyone help point me in the right direction? Thanks!
I have developed a game called Zener and I am trying to resolve a translation bug where the names of the pieces aren't translated in the description from states.inc.php.
I have this in states.inc.php:
Code: Select all
"description" => clienttranslate( '${actplayer} must move ${mandatory_move} piece' ),
"descriptionmyturn" => clienttranslate( '${you} must move ${mandatory_move} piece' ),
Code: Select all
in setupNewGame:
$tmp = clienttranslate( '${actplayer} must move the circle piece' );
$tmp = clienttranslate( '${actplayer} must move the square piece' );
$tmp = clienttranslate( '${actplayer} must move the waves piece' );
$tmp = clienttranslate( '${actplayer} must move the star piece' );
$tmp = clienttranslate( '${actplayer} must move the cross piece' );
$tmp = clienttranslate( '${actplayer} must move any piece' );
$tmp = clienttranslate( '${you} must move the circle piece' );
$tmp = clienttranslate( '${you} must move the square piece' );
$tmp = clienttranslate( '${you} must move the waves piece' );
$tmp = clienttranslate( '${you} must move the star piece' );
$tmp = clienttranslate( '${you} must move the cross piece' );
$tmp = clienttranslate( '${you} must move any piece' );
...
function argsMandatoryChoose()
{
$statement;
$mandatory_move = self::getGameStateValue('mandatory_move');
switch($mandatory_move)
{
case 1:
$statement = clienttranslate( 'the circle' );
break;
case 2:
$statement = clienttranslate( 'the cross' );
break;
case 3:
$statement = clienttranslate( 'the waves' );
break;
case 4:
$statement = clienttranslate( 'the square' );
break;
case 5:
$statement = clienttranslate( 'the star' );
break;
case 0:
default:
$statement = clienttranslate( 'any' );
}
$possible_pieces = self::getPossiblePieces( $mandatory_move );
// we check if the mandatory move can be made in stMandatoryChoose
return array(
'mandatory_move' => $statement,
'possible_pieces' => $possible_pieces
);
}