Contents |
Scorched3D supports the localization of the text used within the client GUI. Any text string present in the client can be changed from the english default to a localized alternative.
Note: Currently only the actual game can be localized, not the launcher program.
None of the text in the GUI is hardcoded (fixed). Each time some text needs to be written to the GUI the actual text to be written is looked up from configuration. This way by changing the configuation is possible to change any text that written. This can be used to simply change the wording of the text displayed or even to change the language of the text.
Every bit of text that needs to be written on the GUI is given a unique key that is used to identify it. It is this unique key that is used to lookup the actual text displayed.
By default english text is associated with all of the keys. Therefore if no configuration is changed english text will be displayed on the GUI.
For example, the cancel buttons on the GUI use a key called CANCEL. Before writing the cancel text on the button a lookup is performed to see what text is registered against the CANCEL key. By default the english text "Cancel" is registered.
The text used for the client GUIs is stored within a configuration file. This file contains mappings from the keys to the text actualy displayed. The configuration file is called lang.resource and can be found in the Scorched3D data directory/lang.
scorched3d
|
+--->data
|
+-->lang
|
+-->lang.resource
|
+-->lang_undefined.resource
This file is a normal ascii text file containing <key>=<value> pairs on each line. For example:
MoneyStarting = Starting Money CANCEL = Cancel KEY1 = Value1 .... KEYn = Valuen
There is another file in this directory called lang_undefined.resource. This file will contain any keys not defined in the lang.resource file along with their english default values. This can be useful in determining what the keys are for each bit of text on the gui. This file is updated everytime the client GUI exits.
Many languages use characters outside of the standard ASCII range. These characters can be entered in the lang.resource file using unicode escape sequences. The escape sequence is defined as \u<Unicode Number>. This <Unicode Number> is written in hexidecimal and must be padded to be four digits in length.
For example the greek letter alpha is unicode character number 945 decimal or 3b1 in hexidecimal. So to represent this character in the lang.resource file you can use \u03B1 .
alpha - letter 945 - unicode number of the letter in decimal 03b1 - unicode number of the letter in hexidecimal padded to 4 digits \u03b1 - escape sequence representing apha
Or to put alpha into the lang.resource file.
alpha = \u03b1 alphabetaalpha = \u03b1\u03b2\u03b1 helloalphabye = hello\u03b1bye
Some of the text on the GUI is parameterized. This means that some of the text displayed is calculated or comes from the game and not from the configuration files.
For example, if the GUI wanted to say "Hello <username>", where <username> is the name of the current player, then this couldn't be hardcoded. The "Hello " part would need be localized but the "<username>" would need to be provided by the game.
This is supported through parameterized values in the lang.resource file. Parameters in the file are represented via the {0}...{n} syntax. The first parameter is {0} the second {1} etc...
So for the "Hello <username>" example this would be written as:
HELLO = Hello {0}
As the game passes the username as the first parameter.
Parameters can be used in the value in any order. So these are valid:
MESSAGE1 = {0} Killed {1}
MESSAGE2 = {1} Was killed by {0}
The localization system used for Scorched3D is very similar to the resource bundle and message format system used by Java. Any resource bundle tools that create java PropertyResourceBundle files should mostly work with Scorched3D.