Hi,
What is the most straightforward way to provide buttons with translatable text. This text being brought by the PHP side:
I think 'i18n' can't work, since I do not bring these values as part of a log.
1. Should I pass these buttons in the log as parameters like ${button_opt_1}, ${button_opt_2}... then ovveride format_string_recursive to wrap these texts into buttons instead of doing that in onUpdateActionButtons?
2. Is there anything smarter and/or more concise?
Thanks for your help!
Tcheby
What is the most straightforward way to provide buttons with translatable text. This text being brought by the PHP side:
Code: Select all
// In my_game.game.php
function argMyState() {
...
// Define each available option: 1 option => 1 button on JS side
$options = array(array('value' => 1, 'text' => clienttranslate("Yes")), array('value' => 0, 'text' => clienttranslate("No")));
...
return array(
'options' => $options,
... // Any other parameters useful for this state
);
}
// In my_game.js
onUpdateActionButtons: function(stateName, args) {
if(this.isCurrentPlayerActive()) {
switch(stateName) {
case 'myState':
// Add a button for each available option
for(var i=0; i<args.options.length; i++) {
var option = args.options[i];
this.addActionButton("choice_" + option.value, _(option.text), "action_clicForChoose")
}
break;
...
default:
break;
}
}
},
1. Should I pass these buttons in the log as parameters like ${button_opt_1}, ${button_opt_2}... then ovveride format_string_recursive to wrap these texts into buttons instead of doing that in onUpdateActionButtons?
2. Is there anything smarter and/or more concise?
Thanks for your help!
Tcheby