This is a documentation for Board Game Arena: play board games online !
Translations: diferència entre les revisions
Cap resum de modificació |
Cap resum de modificació |
||
Línia 1: | Línia 1: | ||
Using BGA Studio, the game you create is ready to be translated to each language by the BGA community. To make this possible, you only need to specify which string must be translated and how to combine them. | |||
: | |||
; | == How translation works? == | ||
When developing your game, all strings must be in English. Strings must be coherent with the English version of the game. | |||
Before the release of the game, BGA team will do the French translation of the game. | |||
After the release of the game, the BGA players community will translate the game in every language. | |||
== What should be translated? == | |||
Every text that can be visible by the player when the game is running normally. This includes tooltips, texts on cards, error messages, ... | |||
This does NOT include error messages that are not supposed to happened (unexpected errors). | |||
== Focus on translating notifications == | |||
Usually, translating a website is simple: you just call a function on every string you have to translate, and the string is translated in the player's language. On Board Game Arena, this is exactly the same with the "_( string )" function. | |||
However, there is one difference on BGA: notifications. The server is sending notifications to players, and most of the time the notifications are the same for every players, no matter what language each player is using. This is why notifications are translated on client side in the proper language, even if the strings are defined on server side. | |||
== On client side (Javascript) == | |||
On client side, things are quite simple: you just have to use the "_()" function for all strings you want to translate. | |||
Examples: | |||
<pre> | |||
// Get a string in player's language: | |||
var translated = _("original english string"); | |||
// Get a string in player's language with parameter: | |||
var translated = dojo.string.substitute( "You can pick ${p} cards and discard ${d}", { | |||
p: 2, | |||
d: 4 | |||
} ); | |||
</pre> | |||
Note: what is also possible to do is | |||
== On server side (PHP) == | |||
On PHP side, you can use 3 different functions to specify that a string must be translated. | |||
'''clienttranslate( "my string to translate" ):''' | |||
This function is '''transparent''': it will return the original English string without any change. It's only purpose is to mark this string as "must be translated", and to make sure the translated version of the string will be available on client side. | |||
In general, you use clienttranslate: | |||
* On your states.inc.php, for field "description" and "descriptionmyturn". | |||
* On "material.inc.php", when defining texts for game material that must be displayed on client side. | |||
* When sending a notification with "notifyAllPlayers" or "notifyPlayer", for the game log string and all game log arguments that need a translation. | |||
'''self::_( "my string to translate" ):''' | |||
This function returns a string translated in the language of CURRENT user (ie: player who send the request to the server) (be careful, this is NOT the active player). | |||
Most of the time, you don't need to translate strings on server side, except on the following 3 situations: | |||
* When throwing an exception because the player did a forbidden move. | |||
* In "yourgame.view.php", when creating the labels for the game interface used in your template (.tpl) file. | |||
* Eventually, in your material.inc.php, if for example you need to use some string elements in your exceptions. | |||
* Eventually, in your "getAllDatas" PHP method, as the data return by this method is used only by current user. |
Revisió del 17:55, 15 gen 2013
Using BGA Studio, the game you create is ready to be translated to each language by the BGA community. To make this possible, you only need to specify which string must be translated and how to combine them.
How translation works?
When developing your game, all strings must be in English. Strings must be coherent with the English version of the game.
Before the release of the game, BGA team will do the French translation of the game.
After the release of the game, the BGA players community will translate the game in every language.
What should be translated?
Every text that can be visible by the player when the game is running normally. This includes tooltips, texts on cards, error messages, ...
This does NOT include error messages that are not supposed to happened (unexpected errors).
Focus on translating notifications
Usually, translating a website is simple: you just call a function on every string you have to translate, and the string is translated in the player's language. On Board Game Arena, this is exactly the same with the "_( string )" function.
However, there is one difference on BGA: notifications. The server is sending notifications to players, and most of the time the notifications are the same for every players, no matter what language each player is using. This is why notifications are translated on client side in the proper language, even if the strings are defined on server side.
On client side (Javascript)
On client side, things are quite simple: you just have to use the "_()" function for all strings you want to translate.
Examples:
// Get a string in player's language: var translated = _("original english string"); // Get a string in player's language with parameter: var translated = dojo.string.substitute( "You can pick ${p} cards and discard ${d}", { p: 2, d: 4 } );
Note: what is also possible to do is
On server side (PHP)
On PHP side, you can use 3 different functions to specify that a string must be translated.
clienttranslate( "my string to translate" ):
This function is transparent: it will return the original English string without any change. It's only purpose is to mark this string as "must be translated", and to make sure the translated version of the string will be available on client side.
In general, you use clienttranslate:
- On your states.inc.php, for field "description" and "descriptionmyturn".
- On "material.inc.php", when defining texts for game material that must be displayed on client side.
- When sending a notification with "notifyAllPlayers" or "notifyPlayer", for the game log string and all game log arguments that need a translation.
self::_( "my string to translate" ):
This function returns a string translated in the language of CURRENT user (ie: player who send the request to the server) (be careful, this is NOT the active player).
Most of the time, you don't need to translate strings on server side, except on the following 3 situations:
- When throwing an exception because the player did a forbidden move.
- In "yourgame.view.php", when creating the labels for the game interface used in your template (.tpl) file.
- Eventually, in your material.inc.php, if for example you need to use some string elements in your exceptions.
- Eventually, in your "getAllDatas" PHP method, as the data return by this method is used only by current user.