L10n
The value of an l10n field: an l10n key, whose text is looked up with the active Archmage.I18n.
Inherits: RefCounted
Set get_i18n and get_preferred_language once, such as in an autoload:
func _ready() -> void: L10n.get_i18n = get_i18n L10n.get_preferred_language = get_preferred_languageSet them to methods, as above, or to static functions. If a lambda is still set when the game exits, Godot 4.6.3 aborts; to use a lambda, set the variable back to Callable() before exit, such as in Node._exit_tree().
== compares two L10n objects, not their keys; compare key instead.
Properties
Section titled “Properties”static var EMPTY: L10nThe L10n whose key is empty. A null or empty JSON value converts to it.
get_i18n
Section titled “get_i18n”static var get_i18n: CallableReturns the active Archmage.I18n. Set it before reading text or calling get_text().
get_preferred_language
Section titled “get_preferred_language”static var get_preferred_language: CallableReturns the player’s preferred language. Set it before reading text.
var key: StringThe l10n key. Read-only.
var text: StringThe text in the preferred language, or in the fallback language when the preferred language has none, or key itself when neither has it. An empty key gives an empty string. Read-only.
Constructor
Section titled “Constructor”L10n.new(p_key: String = "")Methods
Section titled “Methods”from_json()
Section titled “from_json()”static func from_json(v: Variant, _e: Archmage.ParseError = null) -> L10nConverts v, the JSON value of an l10n field, to an L10n. A value that is not a string gives EMPTY, and the type mismatch is recorded in _e (see Archmage.ParseError.report_mismatch()).
to_json()
Section titled “to_json()”func to_json() -> StringReturns the l10n key.
get_text()
Section titled “get_text()”func get_text(lang: String) -> VariantReturns the text in lang, or in the fallback language when lang has none, or null when neither has it. An empty key gives an empty string.