i18n on array structure

Game development with Board Game Arena Studio
Post Reply
User avatar
Woodruff
Posts: 423
Joined: 08 March 2014, 00:53

i18n on array structure

Post by Woodruff »

Hi everybody,

In my gameXXX.game.php, I send an array of array which contains strings to be translated on client-side.
Here is a simplified static example in the getAllDatas function:

Code: Select all

$result['hand']= [
	[ /* 1st card */
		[
			/* 1st text */
			'i18n': ['str']
			'str': $var; // marked earlier as translatable with clienttranslate("")
			// …
		],
		[
			/* 2nd text */
			'i18n': ['str']
			'str': $var2; // marked earlier as translatable with clienttranslate("")
			// …
		],
		// …
	],
	[ /* 2nd card */
		// …
	],
	// ...
]
Will this be sufficiant for the i18n system to work in that context or do I have to add something for translation to take place for the client?

Thanks for your insights!

Wood
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: i18n on array structure

Post by Tisaac »

User avatar
Woodruff
Posts: 423
Joined: 08 March 2014, 00:53

Re: i18n on array structure

Post by Woodruff »

Tisaac wrote: 16 June 2022, 14:58 I advice you to read that page :https://bga-devs.github.io/blog/posts/t ... s-summary/
Thanks Tisaac,

That is very informative, I did not know this ressounce. I think I will use some other tips presented from now on, especially the CSS flex part to replace the Stock component.
(Are you the author of that blog? Big thanks to him no matter what!)

My case does not involve text nesting (log inside log). So, if I understand well, if I summon this in js:

Code: Select all

var card_text = _(cards[i][j].str)
to directly be put inside the HTML tree with no additionnal text, that should work natively since:
  • The string is declared to be translated in PHP (clienttranslate);
  • The string fetched on client side will match exactly the one marked for translation.
Correct?
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: i18n on array structure

Post by Tisaac »

Woodruff wrote: 17 June 2022, 15:55
Tisaac wrote: 16 June 2022, 14:58 I advice you to read that page :https://bga-devs.github.io/blog/posts/t ... s-summary/
Thanks Tisaac,

That is very informative, I did not know this ressounce. I think I will use some other tips presented from now on, especially the CSS flex part to replace the Stock component.
(Are you the author of that blog? Big thanks to him no matter what!)

My case does not involve text nesting (log inside log). So, if I understand well, if I summon this in js:

Code: Select all

var card_text = _(cards[i][j].str)
to directly be put inside the HTML tree with no additionnal text, that should work natively since:
  • The string is declared to be translated in PHP (clienttranslate);
  • The string fetched on client side will match exactly the one marked for translation.
Correct?
Exactly !
I created the blog, but i am not the only author, it's made by community so anyone can post one :)
User avatar
Woodruff
Posts: 423
Joined: 08 March 2014, 00:53

Re: i18n on array structure

Post by Woodruff »

Tisaac wrote: 17 June 2022, 19:31 Exactly !
I created the blog, but i am not the only author, it's made by community so anyone can post one :)
Cool, for once, that is simple!

Thanks for the blog initiative, I may post something about ovveriding format_string_recursive for logging colored symbols in an easy way, if I have time (especially for card games; ♥ ♦ ♣ ♠ K Q J and so on…).
Post Reply

Return to “Developers”