class_translationdomain.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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/TranslationDomain.xml.
  6. .. _class_TranslationDomain:
  7. TranslationDomain
  8. =================
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A self-contained collection of :ref:`Translation<class_Translation>` resources.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **TranslationDomain** is a self-contained collection of :ref:`Translation<class_Translation>` resources. Translations can be added to or removed from it.
  15. If you're working with the main translation domain, it is more convenient to use the wrap methods on :ref:`TranslationServer<class_TranslationServer>`.
  16. .. rst-class:: classref-reftable-group
  17. Properties
  18. ----------
  19. .. table::
  20. :widths: auto
  21. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  22. | :ref:`bool<class_bool>` | :ref:`pseudolocalization_accents_enabled<class_TranslationDomain_property_pseudolocalization_accents_enabled>` | ``true`` |
  23. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  24. | :ref:`bool<class_bool>` | :ref:`pseudolocalization_double_vowels_enabled<class_TranslationDomain_property_pseudolocalization_double_vowels_enabled>` | ``false`` |
  25. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  26. | :ref:`bool<class_bool>` | :ref:`pseudolocalization_enabled<class_TranslationDomain_property_pseudolocalization_enabled>` | ``false`` |
  27. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  28. | :ref:`float<class_float>` | :ref:`pseudolocalization_expansion_ratio<class_TranslationDomain_property_pseudolocalization_expansion_ratio>` | ``0.0`` |
  29. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  30. | :ref:`bool<class_bool>` | :ref:`pseudolocalization_fake_bidi_enabled<class_TranslationDomain_property_pseudolocalization_fake_bidi_enabled>` | ``false`` |
  31. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  32. | :ref:`bool<class_bool>` | :ref:`pseudolocalization_override_enabled<class_TranslationDomain_property_pseudolocalization_override_enabled>` | ``false`` |
  33. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  34. | :ref:`String<class_String>` | :ref:`pseudolocalization_prefix<class_TranslationDomain_property_pseudolocalization_prefix>` | ``"["`` |
  35. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  36. | :ref:`bool<class_bool>` | :ref:`pseudolocalization_skip_placeholders_enabled<class_TranslationDomain_property_pseudolocalization_skip_placeholders_enabled>` | ``true`` |
  37. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  38. | :ref:`String<class_String>` | :ref:`pseudolocalization_suffix<class_TranslationDomain_property_pseudolocalization_suffix>` | ``"]"`` |
  39. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  40. .. rst-class:: classref-reftable-group
  41. Methods
  42. -------
  43. .. table::
  44. :widths: auto
  45. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | |void| | :ref:`add_translation<class_TranslationDomain_method_add_translation>`\ (\ translation\: :ref:`Translation<class_Translation>`\ ) |
  47. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | |void| | :ref:`clear<class_TranslationDomain_method_clear>`\ (\ ) |
  49. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`Translation<class_Translation>` | :ref:`get_translation_object<class_TranslationDomain_method_get_translation_object>`\ (\ locale\: :ref:`String<class_String>`\ ) |const| |
  51. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`StringName<class_StringName>` | :ref:`pseudolocalize<class_TranslationDomain_method_pseudolocalize>`\ (\ message\: :ref:`StringName<class_StringName>`\ ) |const| |
  53. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | |void| | :ref:`remove_translation<class_TranslationDomain_method_remove_translation>`\ (\ translation\: :ref:`Translation<class_Translation>`\ ) |
  55. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`StringName<class_StringName>` | :ref:`translate<class_TranslationDomain_method_translate>`\ (\ message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
  57. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`StringName<class_StringName>` | :ref:`translate_plural<class_TranslationDomain_method_translate_plural>`\ (\ message\: :ref:`StringName<class_StringName>`, message_plural\: :ref:`StringName<class_StringName>`, n\: :ref:`int<class_int>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
  59. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. .. rst-class:: classref-section-separator
  61. ----
  62. .. rst-class:: classref-descriptions-group
  63. Property Descriptions
  64. ---------------------
  65. .. _class_TranslationDomain_property_pseudolocalization_accents_enabled:
  66. .. rst-class:: classref-property
  67. :ref:`bool<class_bool>` **pseudolocalization_accents_enabled** = ``true`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_accents_enabled>`
  68. .. rst-class:: classref-property-setget
  69. - |void| **set_pseudolocalization_accents_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  70. - :ref:`bool<class_bool>` **is_pseudolocalization_accents_enabled**\ (\ )
  71. Replace all characters with their accented variants during pseudolocalization.
  72. \ **Note:** Updating this property does not automatically update texts in the scene tree. Please propagate the :ref:`MainLoop.NOTIFICATION_TRANSLATION_CHANGED<class_MainLoop_constant_NOTIFICATION_TRANSLATION_CHANGED>` notification manually after you have finished modifying pseudolocalization related options.
  73. .. rst-class:: classref-item-separator
  74. ----
  75. .. _class_TranslationDomain_property_pseudolocalization_double_vowels_enabled:
  76. .. rst-class:: classref-property
  77. :ref:`bool<class_bool>` **pseudolocalization_double_vowels_enabled** = ``false`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_double_vowels_enabled>`
  78. .. rst-class:: classref-property-setget
  79. - |void| **set_pseudolocalization_double_vowels_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  80. - :ref:`bool<class_bool>` **is_pseudolocalization_double_vowels_enabled**\ (\ )
  81. Double vowels in strings during pseudolocalization to simulate the lengthening of text due to localization.
  82. \ **Note:** Updating this property does not automatically update texts in the scene tree. Please propagate the :ref:`MainLoop.NOTIFICATION_TRANSLATION_CHANGED<class_MainLoop_constant_NOTIFICATION_TRANSLATION_CHANGED>` notification manually after you have finished modifying pseudolocalization related options.
  83. .. rst-class:: classref-item-separator
  84. ----
  85. .. _class_TranslationDomain_property_pseudolocalization_enabled:
  86. .. rst-class:: classref-property
  87. :ref:`bool<class_bool>` **pseudolocalization_enabled** = ``false`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_enabled>`
  88. .. rst-class:: classref-property-setget
  89. - |void| **set_pseudolocalization_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  90. - :ref:`bool<class_bool>` **is_pseudolocalization_enabled**\ (\ )
  91. If ``true``, enables pseudolocalization for the project. This can be used to spot untranslatable strings or layout issues that may occur once the project is localized to languages that have longer strings than the source language.
  92. \ **Note:** Updating this property does not automatically update texts in the scene tree. Please propagate the :ref:`MainLoop.NOTIFICATION_TRANSLATION_CHANGED<class_MainLoop_constant_NOTIFICATION_TRANSLATION_CHANGED>` notification manually after you have finished modifying pseudolocalization related options.
  93. .. rst-class:: classref-item-separator
  94. ----
  95. .. _class_TranslationDomain_property_pseudolocalization_expansion_ratio:
  96. .. rst-class:: classref-property
  97. :ref:`float<class_float>` **pseudolocalization_expansion_ratio** = ``0.0`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_expansion_ratio>`
  98. .. rst-class:: classref-property-setget
  99. - |void| **set_pseudolocalization_expansion_ratio**\ (\ value\: :ref:`float<class_float>`\ )
  100. - :ref:`float<class_float>` **get_pseudolocalization_expansion_ratio**\ (\ )
  101. The expansion ratio to use during pseudolocalization. A value of ``0.3`` is sufficient for most practical purposes, and will increase the length of each string by 30%.
  102. \ **Note:** Updating this property does not automatically update texts in the scene tree. Please propagate the :ref:`MainLoop.NOTIFICATION_TRANSLATION_CHANGED<class_MainLoop_constant_NOTIFICATION_TRANSLATION_CHANGED>` notification manually after you have finished modifying pseudolocalization related options.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_TranslationDomain_property_pseudolocalization_fake_bidi_enabled:
  106. .. rst-class:: classref-property
  107. :ref:`bool<class_bool>` **pseudolocalization_fake_bidi_enabled** = ``false`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_fake_bidi_enabled>`
  108. .. rst-class:: classref-property-setget
  109. - |void| **set_pseudolocalization_fake_bidi_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  110. - :ref:`bool<class_bool>` **is_pseudolocalization_fake_bidi_enabled**\ (\ )
  111. If ``true``, emulate bidirectional (right-to-left) text when pseudolocalization is enabled. This can be used to spot issues with RTL layout and UI mirroring that will crop up if the project is localized to RTL languages such as Arabic or Hebrew.
  112. \ **Note:** Updating this property does not automatically update texts in the scene tree. Please propagate the :ref:`MainLoop.NOTIFICATION_TRANSLATION_CHANGED<class_MainLoop_constant_NOTIFICATION_TRANSLATION_CHANGED>` notification manually after you have finished modifying pseudolocalization related options.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_TranslationDomain_property_pseudolocalization_override_enabled:
  116. .. rst-class:: classref-property
  117. :ref:`bool<class_bool>` **pseudolocalization_override_enabled** = ``false`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_override_enabled>`
  118. .. rst-class:: classref-property-setget
  119. - |void| **set_pseudolocalization_override_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  120. - :ref:`bool<class_bool>` **is_pseudolocalization_override_enabled**\ (\ )
  121. Replace all characters in the string with ``*``. Useful for finding non-localizable strings.
  122. \ **Note:** Updating this property does not automatically update texts in the scene tree. Please propagate the :ref:`MainLoop.NOTIFICATION_TRANSLATION_CHANGED<class_MainLoop_constant_NOTIFICATION_TRANSLATION_CHANGED>` notification manually after you have finished modifying pseudolocalization related options.
  123. .. rst-class:: classref-item-separator
  124. ----
  125. .. _class_TranslationDomain_property_pseudolocalization_prefix:
  126. .. rst-class:: classref-property
  127. :ref:`String<class_String>` **pseudolocalization_prefix** = ``"["`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_prefix>`
  128. .. rst-class:: classref-property-setget
  129. - |void| **set_pseudolocalization_prefix**\ (\ value\: :ref:`String<class_String>`\ )
  130. - :ref:`String<class_String>` **get_pseudolocalization_prefix**\ (\ )
  131. Prefix that will be prepended to the pseudolocalized string.
  132. \ **Note:** Updating this property does not automatically update texts in the scene tree. Please propagate the :ref:`MainLoop.NOTIFICATION_TRANSLATION_CHANGED<class_MainLoop_constant_NOTIFICATION_TRANSLATION_CHANGED>` notification manually after you have finished modifying pseudolocalization related options.
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_TranslationDomain_property_pseudolocalization_skip_placeholders_enabled:
  136. .. rst-class:: classref-property
  137. :ref:`bool<class_bool>` **pseudolocalization_skip_placeholders_enabled** = ``true`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_skip_placeholders_enabled>`
  138. .. rst-class:: classref-property-setget
  139. - |void| **set_pseudolocalization_skip_placeholders_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  140. - :ref:`bool<class_bool>` **is_pseudolocalization_skip_placeholders_enabled**\ (\ )
  141. Skip placeholders for string formatting like ``%s`` or ``%f`` during pseudolocalization. Useful to identify strings which need additional control characters to display correctly.
  142. \ **Note:** Updating this property does not automatically update texts in the scene tree. Please propagate the :ref:`MainLoop.NOTIFICATION_TRANSLATION_CHANGED<class_MainLoop_constant_NOTIFICATION_TRANSLATION_CHANGED>` notification manually after you have finished modifying pseudolocalization related options.
  143. .. rst-class:: classref-item-separator
  144. ----
  145. .. _class_TranslationDomain_property_pseudolocalization_suffix:
  146. .. rst-class:: classref-property
  147. :ref:`String<class_String>` **pseudolocalization_suffix** = ``"]"`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_suffix>`
  148. .. rst-class:: classref-property-setget
  149. - |void| **set_pseudolocalization_suffix**\ (\ value\: :ref:`String<class_String>`\ )
  150. - :ref:`String<class_String>` **get_pseudolocalization_suffix**\ (\ )
  151. Suffix that will be appended to the pseudolocalized string.
  152. \ **Note:** Updating this property does not automatically update texts in the scene tree. Please propagate the :ref:`MainLoop.NOTIFICATION_TRANSLATION_CHANGED<class_MainLoop_constant_NOTIFICATION_TRANSLATION_CHANGED>` notification manually after you have finished modifying pseudolocalization related options.
  153. .. rst-class:: classref-section-separator
  154. ----
  155. .. rst-class:: classref-descriptions-group
  156. Method Descriptions
  157. -------------------
  158. .. _class_TranslationDomain_method_add_translation:
  159. .. rst-class:: classref-method
  160. |void| **add_translation**\ (\ translation\: :ref:`Translation<class_Translation>`\ ) :ref:`🔗<class_TranslationDomain_method_add_translation>`
  161. Adds a translation.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_TranslationDomain_method_clear:
  165. .. rst-class:: classref-method
  166. |void| **clear**\ (\ ) :ref:`🔗<class_TranslationDomain_method_clear>`
  167. Removes all translations.
  168. .. rst-class:: classref-item-separator
  169. ----
  170. .. _class_TranslationDomain_method_get_translation_object:
  171. .. rst-class:: classref-method
  172. :ref:`Translation<class_Translation>` **get_translation_object**\ (\ locale\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_TranslationDomain_method_get_translation_object>`
  173. Returns the :ref:`Translation<class_Translation>` instance that best matches ``locale``. Returns ``null`` if there are no matches.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_TranslationDomain_method_pseudolocalize:
  177. .. rst-class:: classref-method
  178. :ref:`StringName<class_StringName>` **pseudolocalize**\ (\ message\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_TranslationDomain_method_pseudolocalize>`
  179. Returns the pseudolocalized string based on the ``message`` passed in.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _class_TranslationDomain_method_remove_translation:
  183. .. rst-class:: classref-method
  184. |void| **remove_translation**\ (\ translation\: :ref:`Translation<class_Translation>`\ ) :ref:`🔗<class_TranslationDomain_method_remove_translation>`
  185. Removes the given translation.
  186. .. rst-class:: classref-item-separator
  187. ----
  188. .. _class_TranslationDomain_method_translate:
  189. .. rst-class:: classref-method
  190. :ref:`StringName<class_StringName>` **translate**\ (\ message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_TranslationDomain_method_translate>`
  191. Returns the current locale's translation for the given message and context.
  192. .. rst-class:: classref-item-separator
  193. ----
  194. .. _class_TranslationDomain_method_translate_plural:
  195. .. rst-class:: classref-method
  196. :ref:`StringName<class_StringName>` **translate_plural**\ (\ message\: :ref:`StringName<class_StringName>`, message_plural\: :ref:`StringName<class_StringName>`, n\: :ref:`int<class_int>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_TranslationDomain_method_translate_plural>`
  197. Returns the current locale's translation for the given message, plural message and context.
  198. 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.
  199. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  200. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  201. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  202. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  203. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  204. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  205. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  206. .. |void| replace:: :abbr:`void (No return value.)`