TranslationServer

Inherits: Object

Server that manages all translations.

Description

Server that manages all translations. Translations can be set to it and removed from it.

Methods

void

add_translation ( Translation translation )

void

clear ( )

Array

get_loaded_locales ( ) const

String

get_locale ( ) const

String

get_locale_name ( String locale ) const

Translation

get_translation_object ( String locale )

StringName

pseudolocalize ( StringName message ) const

void

reload_pseudolocalization ( )

void

remove_translation ( Translation translation )

void

set_locale ( String locale )

StringName

translate ( StringName message, StringName context="" ) const

StringName

translate_plural ( StringName message, StringName plural_message, int n, StringName context="" ) const

Property Descriptions

  • bool pseudolocalization_enabled

Default

false

Setter

set_pseudolocalization_enabled(value)

Getter

is_pseudolocalization_enabled()

If true, enables the use of pseudolocalization. See ProjectSettings.internationalization/pseudolocalization/use_pseudolocalization for details.

Method Descriptions

Adds a Translation resource.


  • void clear ( )

Clears the server from all translations.


  • Array get_loaded_locales ( ) const

Returns an array of all loaded locales of the project.


Returns the current locale of the project.

See also OS.get_locale and OS.get_locale_language to query the locale of the user system.


Returns a locale's language and its variant (e.g. "en_US" would return "English (United States)").


Returns the Translation instance based on the locale passed in.

It will return a nullptr if there is no Translation instance that matches the locale.


Returns the pseudolocalized string based on the p_message passed in.


  • void reload_pseudolocalization ( )

Reparses the pseudolocalization options and reloads the translation.


Removes the given translation from the server.


  • void set_locale ( String locale )

Sets the locale of the project. The locale string will be standardized to match known locales (e.g. en-US would be matched to en_US).

If translations have been loaded beforehand for the new locale, they will be applied.


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


Returns the current locale's translation for the given message (key), 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.