Class reference
Translation
Inherits Resource
A language translation that maps a collection of strings to their individual translations.
Description
Translations are resources that can be loaded and unloaded on demand. They map a collection of strings to their individual translations, and they also provide convenience methods for pluralization.
Properties
String locale = "en"
String locale = "en"The locale of the translation.
Methods
StringName _get_message(StringName src_message, StringName context) virtual const
StringName _get_message(StringName src_message, StringName context) virtual constVirtual method to override get_message().
StringName _get_plural_message(StringName src_message, StringName src_plural_message, int n, StringName context) virtual const
StringName _get_plural_message(StringName src_message, StringName src_plural_message, int n, StringName context) virtual constVirtual method to override get_plural_message().
void add_message(StringName src_message, StringName xlated_message, StringName context = &"")
StringName src_message, StringName xlated_message, StringName context = &"")Adds a message if nonexistent, followed by its translation. An additional context could be used to specify the translation context or differentiate polysemic words.
void add_plural_message(StringName src_message, PackedStringArray xlated_messages, StringName context = &"")
StringName src_message, PackedStringArray xlated_messages, StringName context = &"")Adds a message involving plural translation if nonexistent, followed by its translation. An additional context could be used to specify the translation context or differentiate polysemic words. Note: Plurals are only supported in gettext-based translations (PO), not CSV.
void erase_message(StringName src_message, StringName context = &"")
StringName src_message, StringName context = &"")Erases a message.
StringName get_message(StringName src_message, StringName context = &"") const
StringName get_message(StringName src_message, StringName context = &"") constReturns a message's translation.
int get_message_count() const
int get_message_count() constReturns the number of existing messages.
PackedStringArray get_message_list() const
PackedStringArray get_message_list() constReturns all the messages (keys).
StringName get_plural_message(StringName src_message, StringName src_plural_message, int n, StringName context = &"") const
StringName get_plural_message(StringName src_message, StringName src_plural_message, int n, StringName context = &"") constReturns a message's translation involving plurals. 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. Note: Plurals are only supported in gettext-based translations (PO), not CSV.
PackedStringArray get_translated_message_list() const
PackedStringArray get_translated_message_list() constReturns all the messages (translated text).