Localizer - stingray.Localizer object reference - Stingray Lua API Reference

stingray.Localizer object reference

Description

The Localizer is a helper interface that offers access to localized strings that are contained in a single specified .strings resource.

A .strings resource can hold localized strings for many different languages. Use Localizer.set_language(), to set the language that should be used for localization.

Example:

my_localizer = stingray.Localizer("resources/levels/level1/dialogue")
local en_string = stingray.Localizer.lookup(my_localizer, "introduction") -- returns default ("en") string
...
stingray.Localizer.set_language("fr") -- or whatever language the player selects
local fr_string = stingray.Localizer.lookup(my_localizer, "introduction") -- returns French string

See also Localizing your game.

Functions

Parameters

self :

stingray.Localizer

Specifies the object instance that this function will act on.

You may use the colon : calling syntax to call this function on an instance of this object. If you do so, you must omit this parameter. For more information, see this Stingray help topic, or this page in the Lua documentation.

key :

string

Specifies the key of the string to retrieve.

Returns

string?

The string with the specified key, or nil if no matching key could be found.

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Parameters

language :

string?

Specifies the language that should be used by the localizer. Use en to use the default language (English).

The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
This function does not return any values.