Translation interface

Aus Notebook
Version vom 5. April 2012, 14:35 Uhr von MartinSojka (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „Translation strings can be added manually to the tables, but are usually read by parsing a ''classname''.t file alongside a normal class file in the same direc…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen

Translation strings can be added manually to the tables, but are usually read by parsing a classname.t file alongside a normal class file in the same directory.

Global methods[Bearbeiten | edit source]

String _(String text, Array params = null) 
Looks up text in the look-up table and returns it if found, else returns it verbatim.
String t(String text, Array params = null) 
Looks up objectname + '.' + text in the look-up table and returns it if found, else returns text
Global.lang 
Array of language strings ("en_US", "en_GB", "de_DE" and so on) in precedence order, or a language string of the only language alone
Global.translation 
Mapping of known look-up tables (mappings) of the translations, indexed by the language string

Interfaces[Bearbeiten | edit source]

translation 
Interface implemented if the object wants to supply custom translations
String translate(String text, Array params = null) 
Method called by t(...) if the object implements the translation interface; if it returns a non-null value (including an empty string), this will be taken in lieu of the look-up tables