:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Translation.xml. .. _class_Translation: Translation =========== **Inherits:** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` **Inherited By:** :ref:`OptimizedTranslation` A language translation that maps a collection of strings to their individual translations. .. rst-class:: classref-introduction-group Description ----------- **Translation**\ s 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. .. rst-class:: classref-introduction-group Tutorials --------- - :doc:`Internationalizing games <../tutorials/i18n/internationalizing_games>` - :doc:`Localization using gettext <../tutorials/i18n/localization_using_gettext>` - :doc:`Locales <../tutorials/i18n/locales>` .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +-----------------------------+--------------------------------------------------+----------+ | :ref:`String` | :ref:`locale` | ``"en"`` | +-----------------------------+--------------------------------------------------+----------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`_get_message`\ (\ src_message\: :ref:`StringName`, context\: :ref:`StringName`\ ) |virtual| |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`_get_plural_message`\ (\ src_message\: :ref:`StringName`, src_plural_message\: :ref:`StringName`, n\: :ref:`int`, context\: :ref:`StringName`\ ) |virtual| |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_message`\ (\ src_message\: :ref:`StringName`, xlated_message\: :ref:`StringName`, context\: :ref:`StringName` = &""\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_plural_message`\ (\ src_message\: :ref:`StringName`, xlated_messages\: :ref:`PackedStringArray`, context\: :ref:`StringName` = &""\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`erase_message`\ (\ src_message\: :ref:`StringName`, context\: :ref:`StringName` = &""\ ) | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`get_message`\ (\ src_message\: :ref:`StringName`, context\: :ref:`StringName` = &""\ ) |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`get_message_count`\ (\ ) |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedStringArray` | :ref:`get_message_list`\ (\ ) |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`get_plural_message`\ (\ src_message\: :ref:`StringName`, src_plural_message\: :ref:`StringName`, n\: :ref:`int`, context\: :ref:`StringName` = &""\ ) |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedStringArray` | :ref:`get_translated_message_list`\ (\ ) |const| | +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_Translation_property_locale: .. rst-class:: classref-property :ref:`String` **locale** = ``"en"`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_locale**\ (\ value\: :ref:`String`\ ) - :ref:`String` **get_locale**\ (\ ) The locale of the translation. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_Translation_private_method__get_message: .. rst-class:: classref-method :ref:`StringName` **_get_message**\ (\ src_message\: :ref:`StringName`, context\: :ref:`StringName`\ ) |virtual| |const| :ref:`🔗` Virtual method to override :ref:`get_message()`. .. rst-class:: classref-item-separator ---- .. _class_Translation_private_method__get_plural_message: .. rst-class:: classref-method :ref:`StringName` **_get_plural_message**\ (\ src_message\: :ref:`StringName`, src_plural_message\: :ref:`StringName`, n\: :ref:`int`, context\: :ref:`StringName`\ ) |virtual| |const| :ref:`🔗` Virtual method to override :ref:`get_plural_message()`. .. rst-class:: classref-item-separator ---- .. _class_Translation_method_add_message: .. rst-class:: classref-method |void| **add_message**\ (\ src_message\: :ref:`StringName`, xlated_message\: :ref:`StringName`, context\: :ref:`StringName` = &""\ ) :ref:`🔗` Adds a message if nonexistent, followed by its translation. An additional context could be used to specify the translation context or differentiate polysemic words. .. rst-class:: classref-item-separator ---- .. _class_Translation_method_add_plural_message: .. rst-class:: classref-method |void| **add_plural_message**\ (\ src_message\: :ref:`StringName`, xlated_messages\: :ref:`PackedStringArray`, context\: :ref:`StringName` = &""\ ) :ref:`🔗` 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 :doc:`gettext-based translations (PO) <../tutorials/i18n/localization_using_gettext>`, not CSV. .. rst-class:: classref-item-separator ---- .. _class_Translation_method_erase_message: .. rst-class:: classref-method |void| **erase_message**\ (\ src_message\: :ref:`StringName`, context\: :ref:`StringName` = &""\ ) :ref:`🔗` Erases a message. .. rst-class:: classref-item-separator ---- .. _class_Translation_method_get_message: .. rst-class:: classref-method :ref:`StringName` **get_message**\ (\ src_message\: :ref:`StringName`, context\: :ref:`StringName` = &""\ ) |const| :ref:`🔗` Returns a message's translation. .. rst-class:: classref-item-separator ---- .. _class_Translation_method_get_message_count: .. rst-class:: classref-method :ref:`int` **get_message_count**\ (\ ) |const| :ref:`🔗` Returns the number of existing messages. .. rst-class:: classref-item-separator ---- .. _class_Translation_method_get_message_list: .. rst-class:: classref-method :ref:`PackedStringArray` **get_message_list**\ (\ ) |const| :ref:`🔗` Returns all the messages (keys). .. rst-class:: classref-item-separator ---- .. _class_Translation_method_get_plural_message: .. rst-class:: classref-method :ref:`StringName` **get_plural_message**\ (\ src_message\: :ref:`StringName`, src_plural_message\: :ref:`StringName`, n\: :ref:`int`, context\: :ref:`StringName` = &""\ ) |const| :ref:`🔗` Returns 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 :doc:`gettext-based translations (PO) <../tutorials/i18n/localization_using_gettext>`, not CSV. .. rst-class:: classref-item-separator ---- .. _class_Translation_method_get_translated_message_list: .. rst-class:: classref-method :ref:`PackedStringArray` **get_translated_message_list**\ (\ ) |const| :ref:`🔗` Returns all the messages (translated text). .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`