(info) Other great resources: Official JS API docs, Scripting Forum

_() localise

Used for string localisation (translation in to other languages)...

 

Syntax

var localisedStr = _("string");

Parameters

ParameterTypeMandatoryNotesGame Version
"string"String literal(tick)

The string to translate. Must be a primitive, string literal.

See Notes section below for more details as to why.

3.1 Beta 1

Return values

ValueTypeNotesGame Version
<localisedStr>String

The localised version of the str.

If no localised version of str exists, str will be returned.

3.1 Beta 1

Notes

Localisation happens in two stages.

The first stage is part of the design/build process, and uses _() merely as a marker for strings that need localisation:

  • A 'gettext' script parses files looking for occurrences of _("some string") – it adds each string it finds to a .po file
  • The .po files are used by translators to create localised versions of the strings
  • The .po files are then compiled in to .mo files that are bundled with the game

For this reason, you can't use variables or constants inside of _(), because that would confuse the gettext script.

Then, at run-time, the _() actually does the localisation:

  • Looks for the string in the relevant .mo file
  • If found, returns the localised string
  • If not found, returns the original string

Currently there's no way to determine what language other players in an MP game speak, and there's no way to specify a target locale in the _() function. See related forum topics for more information.

If you want to know more about localising Warzone 2100, view the official translations topic in the forums.

Example

console(_("hello world")); // translate "hello world" in to user's language
Thanks to everyone in the forums who helped explain the workings of this function!
Availability 3.1 B1+

Requires:

  • Warzone 3.1 Beta 1 or above
Contents

Jump to:

Â