HowTo/Localize an Asset

From TrainzOnline
Jump to: navigation, search

Trainz games are sold in many countries and languages all over the world. This wiki section details how you can make your content compatible with other languages in Trainz.

The Trainz game, as with many computer technologies, is developed in English. Internal structures follow English-language conventions and limitations. For end-user purposes, Trainz includes significant support for localized text such that a typical end-user may play the game entirely in their local language without resorting to the English language. When creating content for the Trainz environment, it is required that a number of English fields are provided. Trainz expects these entries regardless of which language the content creator may be using. In addition, localized variants of each field may be provided to allow the content to be used by non-English speakers.


Language Specific Tags

Assets in Trainz have several tags within their config.txt files which contain language specific data. These are:

username - The username tag contains the asset name. This is the text displayed in the Content Manager list view and in the various selection lists in game.

description - The description tag contains a brief asset description. The asset description is shown in the "Asset Details" panel in Content Manager. For Routes and Sessions the description is also displayed in the Routes/Surveyor/Driver menus in game.

string-table - The string-table container holds miscellaneous strings used by the asset. These entries could be anything from place names in routes/sessions to dialog boxes displayed by Driver scripts.

Each of these tags should be in English. Localised variants can easily be included by adding additional tags with the appropriate two character language suffix to the tag name. For example, to have your asset display with a French name when a player is running in French simply add a "username-fr" tag with the French asset name in addition to the standard "username" in English.

Trainz HTML

Trainz makes use of in game dialogs which are formatted using a markup language similar to HTML. Readable text within Trainz HTML can be translated one of two ways through the use of font locale tags.

The first, and preferred, way of translating Trainz HTML is to use the generic locale. Using the generic locale instructs the Trainz HTML parser to look in an assets string-table for the translated text. When using the generic locale you first create a string-table entry in your asset config.txt file. You then reference this string-table entry between the font tags and the text will be replaced at run-time.

For example:

  html-hello                           "Hello!"
  html-hello                           "Bonjour!"

<font locale=generic>html-hello</font>

If you use the generic locale and a translation is unavailable for a players selected language, the parser will fall back to English.

The alternative, older, way of translating Trainz HTML is to specify the language name in the font locale tag. This method is troublesome, and should be avoided, but is used by many older assets in game and on the Download Station.

For example:

<font locale=english>Hello!</font>
<font locale=french>Bonjour!</font>

If you use this older style of localization and a translation is unavailable for a players selected language, nothing will be displayed.

You can find more information about Trainz HTML and in game script dialogs here.

Example Asset

The following is an example of a fairly simple config.txt file that has been translated into German and French.

 kuid                                    <kuid:-16:2030>
 kind                                    "behavior"
 script                                  "behaviour"
 class                                   "ControlTypeRule"
 icon-texture                            "control_type.texture"
 asset-filename                          "ControlTypeRule"
 username                                "Control Type"
 username-fr                             "Type de contrôle"
 username-de                             "Control Type"
   html_description1                     "Current control method is <a href=live://property/control-method>Cab mode</a>."
   html_description2                     "Current control method is <a href=live://property/control-method>DCC mode</a>."
   html_description3                     "Current control method is <a href=live://property/control-method>Ask user</a>."
   driver_default_msg                    "Defaulting to DCC mode for user train."
   description                           "Set the control method (DCC mode or Cab mode) and realism."
   html_description1                     "Méthode de contrôle actuelle : <a href=live://property/control-method>mode Cabine</a>."
   html_description2                     "Méthode de contrôle actuelle : <a href=live://property/control-method>mode DCC</a>."
   html_description3                     "Méthode de contrôle actuelle : <a href=live://property/control-method>Demander à l'utilisateur</a>."
   driver_default_msg                    "Activation par défaut du mode DCC pour le train de l'utilisateur."
   description                           "Permet de sélectionner la méthode de contrôle (mode DCC ou Cabine) et le niveau de réalisme."
   html_description1                     "Aktuelle Steuerung ist <a href=live://property/control-method>Führerstandsmodus</a>."
   html_description2                     "Aktuelle Steuerung ist <a href=live://property/control-method>Trafo-Modus</a>."
   html_description3                     "Aktuelle Steuerung ist <a href=live://property/control-method>Benutzer fragen</a>."
   driver_default_msg                    "Zurück zum Trafo-Modus für den Zug des Benutzers."
   description                           "Steuerungs-Methode (Trafo- oder Führerstands-Modus) und Realismus auswählen."

See Also

Return to How To Index


Personal tools