Index · Object → RefCounted → TranslationDomain

TranslationDomain

A self-contained collection of Translation resources.

Class Description

TranslationDomain is a self-contained collection of Translation resources. Translations can be added to or removed from it.

If you're working with the main translation domain, it is more convenient to use the wrap methods on TranslationServer.

Properties

var enabled: bool = true

If true, translation is enabled. Otherwise, translate() and translate_plural() will return the input message unchanged regardless of the current locale.

var pseudolocalization_accents_enabled: bool = true

Replace all characters with their accented variants during pseudolocalization.

Note: Updating this property does not automatically update texts in the scene tree. Please propagate the MainLoop.NOTIFICATION_TRANSLATION_CHANGED notification manually after you have finished modifying pseudolocalization related options.

var pseudolocalization_double_vowels_enabled: bool = false

Double vowels in strings during pseudolocalization to simulate the lengthening of text due to localization.

Note: Updating this property does not automatically update texts in the scene tree. Please propagate the MainLoop.NOTIFICATION_TRANSLATION_CHANGED notification manually after you have finished modifying pseudolocalization related options.

var pseudolocalization_enabled: bool = false

If true, enables pseudolocalization for the project. This can be used to spot untranslatable strings or layout issues that may occur once the project is localized to languages that have longer strings than the source language.

Note: Updating this property does not automatically update texts in the scene tree. Please propagate the MainLoop.NOTIFICATION_TRANSLATION_CHANGED notification manually after you have finished modifying pseudolocalization related options.

var pseudolocalization_expansion_ratio: float = 0.0

The expansion ratio to use during pseudolocalization. A value of 0.3 is sufficient for most practical purposes, and will increase the length of each string by 30%.

Note: Updating this property does not automatically update texts in the scene tree. Please propagate the MainLoop.NOTIFICATION_TRANSLATION_CHANGED notification manually after you have finished modifying pseudolocalization related options.

var pseudolocalization_fake_bidi_enabled: bool = false

If true, emulate bidirectional (right-to-left) text when pseudolocalization is enabled. This can be used to spot issues with RTL layout and UI mirroring that will crop up if the project is localized to RTL languages such as Arabic or Hebrew.

Note: Updating this property does not automatically update texts in the scene tree. Please propagate the MainLoop.NOTIFICATION_TRANSLATION_CHANGED notification manually after you have finished modifying pseudolocalization related options.

var pseudolocalization_override_enabled: bool = false

Replace all characters in the string with *. Useful for finding non-localizable strings.

Note: Updating this property does not automatically update texts in the scene tree. Please propagate the MainLoop.NOTIFICATION_TRANSLATION_CHANGED notification manually after you have finished modifying pseudolocalization related options.

var pseudolocalization_prefix: String = "["

Prefix that will be prepended to the pseudolocalized string.

Note: Updating this property does not automatically update texts in the scene tree. Please propagate the MainLoop.NOTIFICATION_TRANSLATION_CHANGED notification manually after you have finished modifying pseudolocalization related options.

var pseudolocalization_skip_placeholders_enabled: bool = true

Skip placeholders for string formatting like %s or %f during pseudolocalization. Useful to identify strings which need additional control characters to display correctly.

Note: Updating this property does not automatically update texts in the scene tree. Please propagate the MainLoop.NOTIFICATION_TRANSLATION_CHANGED notification manually after you have finished modifying pseudolocalization related options.

var pseudolocalization_suffix: String = "]"

Suffix that will be appended to the pseudolocalized string.

Note: Updating this property does not automatically update texts in the scene tree. Please propagate the MainLoop.NOTIFICATION_TRANSLATION_CHANGED notification manually after you have finished modifying pseudolocalization related options.

Methods

func add_translation(translation: Translation) -> void

Adds a translation.

func clear() -> void

Removes all translations.

func find_translations(locale: String, exact: bool) -> Translation[]

Returns the Translation instances that match locale (see TranslationServer.compare_locales()). If exact is true, only instances whose locale exactly equals locale will be returned.

func get_locale_override() -> String

Returns the locale override of the domain. Returns an empty string if locale override is disabled.

func get_translation_object(locale: String) -> Translation

Returns the Translation instance that best matches locale. Returns null if there are no matches.

func get_translations() -> Translation[]

Returns all available Translation instances as added by add_translation().

func has_translation(translation: Translation) -> bool

Returns true if this translation domain contains the given translation.

func has_translation_for_locale(locale: String, exact: bool) -> bool

Returns true if there are any Translation instances that match locale (see TranslationServer.compare_locales()). If exact is true, only instances whose locale exactly equals locale are considered.

func pseudolocalize(message: StringName) -> StringName

Returns the pseudolocalized string based on the message passed in.

func remove_translation(translation: Translation) -> void

Removes the given translation.

func set_locale_override(locale: String) -> void

Sets the locale override of the domain.

If locale is an empty string, locale override is disabled. Otherwise, locale will be standardized to match known locales (e.g. en-US would be matched to en_US).

Note: Calling this method does not automatically update texts in the scene tree. Please propagate the MainLoop.NOTIFICATION_TRANSLATION_CHANGED signal manually.

func translate(message: StringName, context: StringName = &"") -> StringName

Returns the current locale's translation for the given message and context.

func translate_plural(message: StringName, message_plural: StringName, n: int, context: StringName = &"") -> StringName

Returns the current locale's translation for the given message, plural message and context.

The number n is the number or quantity of the plural object. It will be used to guide the translation system to fetch the correct plural form for the selected language.

Inherited from RefCounted (4)
func init_ref() -> bool
func reference() -> bool
func unreference() -> bool
Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from Object (2)