Files
godot-docs/classes/class_translation.rst
2022-07-27 13:59:06 +02:00

163 lines
11 KiB
ReStructuredText

: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<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
**Inherited By:** :ref:`OptimizedTranslation<class_OptimizedTranslation>`
Language Translation.
Description
-----------
Translations are resources that can be loaded and unloaded on demand. They map a string to another string.
Tutorials
---------
- :doc:`Internationalizing games <../tutorials/i18n/internationalizing_games>`
- :doc:`Locales <../tutorials/i18n/locales>`
Properties
----------
+-----------------------------+--------------------------------------------------+----------+
| :ref:`String<class_String>` | :ref:`locale<class_Translation_property_locale>` | ``"en"`` |
+-----------------------------+--------------------------------------------------+----------+
Methods
-------
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`StringName<class_StringName>` | :ref:`_get_message<class_Translation_method__get_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` context **)** |virtual| |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`StringName<class_StringName>` | :ref:`_get_plural_message<class_Translation_method__get_plural_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` src_plural_message, :ref:`int<class_int>` n, :ref:`StringName<class_StringName>` context **)** |virtual| |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_message<class_Translation_method_add_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` xlated_message, :ref:`StringName<class_StringName>` context="" **)** |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_plural_message<class_Translation_method_add_plural_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`PackedStringArray<class_PackedStringArray>` xlated_messages, :ref:`StringName<class_StringName>` context="" **)** |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`erase_message<class_Translation_method_erase_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` context="" **)** |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`StringName<class_StringName>` | :ref:`get_message<class_Translation_method_get_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` context="" **)** |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_message_count<class_Translation_method_get_message_count>` **(** **)** |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_message_list<class_Translation_method_get_message_list>` **(** **)** |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`StringName<class_StringName>` | :ref:`get_plural_message<class_Translation_method_get_plural_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` src_plural_message, :ref:`int<class_int>` n, :ref:`StringName<class_StringName>` context="" **)** |const| |
+---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Property Descriptions
---------------------
.. _class_Translation_property_locale:
- :ref:`String<class_String>` **locale**
+-----------+-------------------+
| *Default* | ``"en"`` |
+-----------+-------------------+
| *Setter* | set_locale(value) |
+-----------+-------------------+
| *Getter* | get_locale() |
+-----------+-------------------+
The locale of the translation.
Method Descriptions
-------------------
.. _class_Translation_method__get_message:
- :ref:`StringName<class_StringName>` **_get_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` context **)** |virtual| |const|
Virtual method to override :ref:`get_message<class_Translation_method_get_message>`.
----
.. _class_Translation_method__get_plural_message:
- :ref:`StringName<class_StringName>` **_get_plural_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` src_plural_message, :ref:`int<class_int>` n, :ref:`StringName<class_StringName>` context **)** |virtual| |const|
Virtual method to override :ref:`get_plural_message<class_Translation_method_get_plural_message>`.
----
.. _class_Translation_method_add_message:
- void **add_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` xlated_message, :ref:`StringName<class_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.
----
.. _class_Translation_method_add_plural_message:
- void **add_plural_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`PackedStringArray<class_PackedStringArray>` xlated_messages, :ref:`StringName<class_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.
----
.. _class_Translation_method_erase_message:
- void **erase_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` context="" **)**
Erases a message.
----
.. _class_Translation_method_get_message:
- :ref:`StringName<class_StringName>` **get_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` context="" **)** |const|
Returns a message's translation.
----
.. _class_Translation_method_get_message_count:
- :ref:`int<class_int>` **get_message_count** **(** **)** |const|
Returns the number of existing messages.
----
.. _class_Translation_method_get_message_list:
- :ref:`PackedStringArray<class_PackedStringArray>` **get_message_list** **(** **)** |const|
Returns all the messages (keys).
----
.. _class_Translation_method_get_plural_message:
- :ref:`StringName<class_StringName>` **get_plural_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` src_plural_message, :ref:`int<class_int>` n, :ref:`StringName<class_StringName>` context="" **)** |const|
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.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |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.)`