Translations in descriptionMyTurn

Game development with Board Game Arena Studio
Post Reply
User avatar
thunder0491
Posts: 12
Joined: 10 April 2023, 11:37

Translations in descriptionMyTurn

Post by thunder0491 »

I am having troubles translating the 'description' and 'descriptionMyTurn'.

As you can see here in this state depending if the player can pass I want to show a message or another, but in Production(my game Catopomp is currently in Beta) the $message and $messageMyTurn is shown always in English mixed with the translation of the first part of the sentence.

In the documentation I found some examples for i18n but they are focused on sending notifications.

Could someone point me in the right direction?

Thank you

Code: Select all

class TransferHellCard extends GameState {
    function __construct(protected Game $game) {
        parent::__construct($game,
            id: 7,
            type: StateType::ACTIVE_PLAYER,
            description: clienttranslate('Since ${actplayer} have ${message} (${otherplayer})'),
            descriptionMyTurn: clienttranslate('Since ${you} have ${messageMyTurn} (${otherplayer})'),
            transitions: [
                'transferCard' => 4,
            ],
            updateGameProgression: false,
            initialPrivate: null,
        );
    }

    function getArgs(): array {
        $hell = $this->game->getPlayerCards((int)$this->game->getActivePlayerId(), "hell");
        $passingPlayer = array_values($this->game->getPlayerWhoIsPassingTurn());
        $canPass = count($hell) < 3;
        if ($canPass) {
            $message = clienttranslate('less than 3 Hell cards, they can transfer one Hell card to the player who passed on their set');
            $messageMyTurn = clienttranslate('less than 3 Hell cards, you can transfer one Hell card to the player who passed on your set');
        }
        else {
            $message = clienttranslate('≥ 3 Hell cards, they must transfer one Hell card to the player who passed on their set');
            $messageMyTurn = clienttranslate('≥ 3 Hell cards, you must transfer one Hell card to the player who passed on your set');
        }

        return [
            'canPass' => $canPass,
            'isTransferPassingMode' => true,
            'message' => $message,
            'messageMyTurn' => $messageMyTurn,
            'otherplayer'=> count($passingPlayer) > 0 ? $passingPlayer[0]['player_name'] : '',
            'otherplayer_id'=> count($passingPlayer) > 0 ? $passingPlayer[0]['player_id'] : ''
        ];
    }
    
User avatar
thoun
Posts: 1666
Joined: 10 December 2020, 22:25

Re: Translations in descriptionMyTurn

Post by thoun »

You're on the good track, i18n should work the same way here as notifications
User avatar
thunder0491
Posts: 12
Joined: 10 April 2023, 11:37

Re: Translations in descriptionMyTurn

Post by thunder0491 »

Thanks, I will give it a try
thoun wrote: ↑02 November 2026, 19:34 You're on the good track, i18n should work the same way here as notifications
Post Reply

Return to “Developers”