clienttranslate does not work in php

Game development with Board Game Arena Studio
Post Reply
BaronBeule
Posts: 5
Joined: 09 January 2021, 20:13

clienttranslate does not work in php

Post by BaronBeule »

I need no generate complex text by concatenation, but nothing works. I tried
sprintf
str_replace
or this:

Code: Select all

self::notifyAllPlayers( "notifLog", clienttranslate( '${player_name} earns 1 x') . ' ' . wood . ' '. clienttranslate( 'Wood.') , array(...
but it only works, if I use it in a static way without any additional code:

Code: Select all

clienttranslate( 'bla bla')
Any help plz, thx
User avatar
robinzig
Posts: 459
Joined: 11 February 2021, 18:23

Re: clienttranslate does not work in php

Post by robinzig »

The answers are all here https://boardgamearena.com/doc/Translations

Basically, concatentation doesn't work in clienttranslate. It's not clear to me from your example what you're trying to do (what is the `wood` that you're trying to concatenate between the clienttranslate calls? It doesn't look like a PHP variable as it doesn't start with a $) - but it should be achievable in one of the ways suggestesd in that doc page, either sprintf or including ${some_variable} inside a single string passed to clienttranslate and with that then in the i18n array of the notification if it needs translation.

You say you tried some of these things, but without saying specifically what you tried we can't know what you did wrong.
User avatar
ufm
Posts: 2039
Joined: 06 January 2017, 08:38

Re: clienttranslate does not work in php

Post by ufm »

robinzig wrote: 12 October 2024, 00:53 The answers are all here https://boardgamearena.com/doc/Translations
FIFY: https://en.doc.boardgamearena.com/Translations

Check this link as well: https://bga-devs.github.io/blog/posts/t ... s-summary/
This link is at the end of the first document, but the recursion is one of the most important aspects in the BGA translation.
Last edited by ufm on 12 October 2024, 11:20, edited 1 time in total.
User avatar
tchobello
Posts: 693
Joined: 18 March 2012, 13:19

Re: clienttranslate does not work in php

Post by tchobello »

Hello,
if you want to write something like 'player_name earns 3 Wood' and 3 is the variable $wood (don't forget the $) :

Code: Select all

self::notifyAllPlayers( "notifLog", clienttranslate( '${player_name} earns ${wood} Wood'), [...] ) ;
If you follow the links and learn more about format_string_recursive, you'll be able to replace Wood by an icon.
BaronBeule
Posts: 5
Joined: 09 January 2021, 20:13

Re: clienttranslate does not work in php

Post by BaronBeule »

thanks all for your quick reply, and yes 'wood' is a typo, it is a php variable and should be $wood ;-)
Post Reply

Return to “Developers”