class_translation.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Translation.xml.
  6. .. _class_Translation:
  7. Translation
  8. ===========
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`OptimizedTranslation<class_OptimizedTranslation>`
  11. A language translation that maps a collection of strings to their individual translations.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. **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.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - :doc:`Internationalizing games <../tutorials/i18n/internationalizing_games>`
  20. - :doc:`Locales <../tutorials/i18n/locales>`
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +-----------------------------+--------------------------------------------------+----------+
  27. | :ref:`String<class_String>` | :ref:`locale<class_Translation_property_locale>` | ``"en"`` |
  28. +-----------------------------+--------------------------------------------------+----------+
  29. .. rst-class:: classref-reftable-group
  30. Methods
  31. -------
  32. .. table::
  33. :widths: auto
  34. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`StringName<class_StringName>` | :ref:`_get_message<class_Translation_private_method__get_message>`\ (\ src_message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>`\ ) |virtual| |const| |
  36. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`StringName<class_StringName>` | :ref:`_get_plural_message<class_Translation_private_method__get_plural_message>`\ (\ src_message\: :ref:`StringName<class_StringName>`, src_plural_message\: :ref:`StringName<class_StringName>`, n\: :ref:`int<class_int>`, context\: :ref:`StringName<class_StringName>`\ ) |virtual| |const| |
  38. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | |void| | :ref:`add_message<class_Translation_method_add_message>`\ (\ src_message\: :ref:`StringName<class_StringName>`, xlated_message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |
  40. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | |void| | :ref:`add_plural_message<class_Translation_method_add_plural_message>`\ (\ src_message\: :ref:`StringName<class_StringName>`, xlated_messages\: :ref:`PackedStringArray<class_PackedStringArray>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |
  42. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | |void| | :ref:`erase_message<class_Translation_method_erase_message>`\ (\ src_message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |
  44. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`StringName<class_StringName>` | :ref:`get_message<class_Translation_method_get_message>`\ (\ src_message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
  46. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`get_message_count<class_Translation_method_get_message_count>`\ (\ ) |const| |
  48. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_message_list<class_Translation_method_get_message_list>`\ (\ ) |const| |
  50. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`StringName<class_StringName>` | :ref:`get_plural_message<class_Translation_method_get_plural_message>`\ (\ src_message\: :ref:`StringName<class_StringName>`, src_plural_message\: :ref:`StringName<class_StringName>`, n\: :ref:`int<class_int>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
  52. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_translated_message_list<class_Translation_method_get_translated_message_list>`\ (\ ) |const| |
  54. +---------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. .. rst-class:: classref-section-separator
  56. ----
  57. .. rst-class:: classref-descriptions-group
  58. Property Descriptions
  59. ---------------------
  60. .. _class_Translation_property_locale:
  61. .. rst-class:: classref-property
  62. :ref:`String<class_String>` **locale** = ``"en"`` :ref:`🔗<class_Translation_property_locale>`
  63. .. rst-class:: classref-property-setget
  64. - |void| **set_locale**\ (\ value\: :ref:`String<class_String>`\ )
  65. - :ref:`String<class_String>` **get_locale**\ (\ )
  66. The locale of the translation.
  67. .. rst-class:: classref-section-separator
  68. ----
  69. .. rst-class:: classref-descriptions-group
  70. Method Descriptions
  71. -------------------
  72. .. _class_Translation_private_method__get_message:
  73. .. rst-class:: classref-method
  74. :ref:`StringName<class_StringName>` **_get_message**\ (\ src_message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>`\ ) |virtual| |const| :ref:`🔗<class_Translation_private_method__get_message>`
  75. Virtual method to override :ref:`get_message<class_Translation_method_get_message>`.
  76. .. rst-class:: classref-item-separator
  77. ----
  78. .. _class_Translation_private_method__get_plural_message:
  79. .. rst-class:: classref-method
  80. :ref:`StringName<class_StringName>` **_get_plural_message**\ (\ src_message\: :ref:`StringName<class_StringName>`, src_plural_message\: :ref:`StringName<class_StringName>`, n\: :ref:`int<class_int>`, context\: :ref:`StringName<class_StringName>`\ ) |virtual| |const| :ref:`🔗<class_Translation_private_method__get_plural_message>`
  81. Virtual method to override :ref:`get_plural_message<class_Translation_method_get_plural_message>`.
  82. .. rst-class:: classref-item-separator
  83. ----
  84. .. _class_Translation_method_add_message:
  85. .. rst-class:: classref-method
  86. |void| **add_message**\ (\ src_message\: :ref:`StringName<class_StringName>`, xlated_message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>` = &""\ ) :ref:`🔗<class_Translation_method_add_message>`
  87. Adds a message if nonexistent, followed by its translation.
  88. An additional context could be used to specify the translation context or differentiate polysemic words.
  89. .. rst-class:: classref-item-separator
  90. ----
  91. .. _class_Translation_method_add_plural_message:
  92. .. rst-class:: classref-method
  93. |void| **add_plural_message**\ (\ src_message\: :ref:`StringName<class_StringName>`, xlated_messages\: :ref:`PackedStringArray<class_PackedStringArray>`, context\: :ref:`StringName<class_StringName>` = &""\ ) :ref:`🔗<class_Translation_method_add_plural_message>`
  94. Adds a message involving plural translation if nonexistent, followed by its translation.
  95. An additional context could be used to specify the translation context or differentiate polysemic words.
  96. .. rst-class:: classref-item-separator
  97. ----
  98. .. _class_Translation_method_erase_message:
  99. .. rst-class:: classref-method
  100. |void| **erase_message**\ (\ src_message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>` = &""\ ) :ref:`🔗<class_Translation_method_erase_message>`
  101. Erases a message.
  102. .. rst-class:: classref-item-separator
  103. ----
  104. .. _class_Translation_method_get_message:
  105. .. rst-class:: classref-method
  106. :ref:`StringName<class_StringName>` **get_message**\ (\ src_message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Translation_method_get_message>`
  107. Returns a message's translation.
  108. .. rst-class:: classref-item-separator
  109. ----
  110. .. _class_Translation_method_get_message_count:
  111. .. rst-class:: classref-method
  112. :ref:`int<class_int>` **get_message_count**\ (\ ) |const| :ref:`🔗<class_Translation_method_get_message_count>`
  113. Returns the number of existing messages.
  114. .. rst-class:: classref-item-separator
  115. ----
  116. .. _class_Translation_method_get_message_list:
  117. .. rst-class:: classref-method
  118. :ref:`PackedStringArray<class_PackedStringArray>` **get_message_list**\ (\ ) |const| :ref:`🔗<class_Translation_method_get_message_list>`
  119. Returns all the messages (keys).
  120. .. rst-class:: classref-item-separator
  121. ----
  122. .. _class_Translation_method_get_plural_message:
  123. .. rst-class:: classref-method
  124. :ref:`StringName<class_StringName>` **get_plural_message**\ (\ src_message\: :ref:`StringName<class_StringName>`, src_plural_message\: :ref:`StringName<class_StringName>`, n\: :ref:`int<class_int>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_Translation_method_get_plural_message>`
  125. Returns a message's translation involving plurals.
  126. 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.
  127. .. rst-class:: classref-item-separator
  128. ----
  129. .. _class_Translation_method_get_translated_message_list:
  130. .. rst-class:: classref-method
  131. :ref:`PackedStringArray<class_PackedStringArray>` **get_translated_message_list**\ (\ ) |const| :ref:`🔗<class_Translation_method_get_translated_message_list>`
  132. Returns all the messages (translated text).
  133. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  134. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  135. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  136. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  137. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  138. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  139. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  140. .. |void| replace:: :abbr:`void (No return value.)`