class_translationdomain.rst 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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:`enabled<class_TranslationDomain_property_enabled>` | ``true`` |
  23. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  24. | :ref:`bool<class_bool>` | :ref:`pseudolocalization_accents_enabled<class_TranslationDomain_property_pseudolocalization_accents_enabled>` | ``true`` |
  25. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  26. | :ref:`bool<class_bool>` | :ref:`pseudolocalization_double_vowels_enabled<class_TranslationDomain_property_pseudolocalization_double_vowels_enabled>` | ``false`` |
  27. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  28. | :ref:`bool<class_bool>` | :ref:`pseudolocalization_enabled<class_TranslationDomain_property_pseudolocalization_enabled>` | ``false`` |
  29. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  30. | :ref:`float<class_float>` | :ref:`pseudolocalization_expansion_ratio<class_TranslationDomain_property_pseudolocalization_expansion_ratio>` | ``0.0`` |
  31. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  32. | :ref:`bool<class_bool>` | :ref:`pseudolocalization_fake_bidi_enabled<class_TranslationDomain_property_pseudolocalization_fake_bidi_enabled>` | ``false`` |
  33. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  34. | :ref:`bool<class_bool>` | :ref:`pseudolocalization_override_enabled<class_TranslationDomain_property_pseudolocalization_override_enabled>` | ``false`` |
  35. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  36. | :ref:`String<class_String>` | :ref:`pseudolocalization_prefix<class_TranslationDomain_property_pseudolocalization_prefix>` | ``"["`` |
  37. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  38. | :ref:`bool<class_bool>` | :ref:`pseudolocalization_skip_placeholders_enabled<class_TranslationDomain_property_pseudolocalization_skip_placeholders_enabled>` | ``true`` |
  39. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  40. | :ref:`String<class_String>` | :ref:`pseudolocalization_suffix<class_TranslationDomain_property_pseudolocalization_suffix>` | ``"]"`` |
  41. +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------+-----------+
  42. .. rst-class:: classref-reftable-group
  43. Methods
  44. -------
  45. .. table::
  46. :widths: auto
  47. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | |void| | :ref:`add_translation<class_TranslationDomain_method_add_translation>`\ (\ translation\: :ref:`Translation<class_Translation>`\ ) |
  49. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | |void| | :ref:`clear<class_TranslationDomain_method_clear>`\ (\ ) |
  51. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`String<class_String>` | :ref:`get_locale_override<class_TranslationDomain_method_get_locale_override>`\ (\ ) |const| |
  53. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`Translation<class_Translation>` | :ref:`get_translation_object<class_TranslationDomain_method_get_translation_object>`\ (\ locale\: :ref:`String<class_String>`\ ) |const| |
  55. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`StringName<class_StringName>` | :ref:`pseudolocalize<class_TranslationDomain_method_pseudolocalize>`\ (\ message\: :ref:`StringName<class_StringName>`\ ) |const| |
  57. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | |void| | :ref:`remove_translation<class_TranslationDomain_method_remove_translation>`\ (\ translation\: :ref:`Translation<class_Translation>`\ ) |
  59. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | |void| | :ref:`set_locale_override<class_TranslationDomain_method_set_locale_override>`\ (\ locale\: :ref:`String<class_String>`\ ) |
  61. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`StringName<class_StringName>` | :ref:`translate<class_TranslationDomain_method_translate>`\ (\ message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
  63. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :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| |
  65. +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. .. rst-class:: classref-section-separator
  67. ----
  68. .. rst-class:: classref-descriptions-group
  69. Property Descriptions
  70. ---------------------
  71. .. _class_TranslationDomain_property_enabled:
  72. .. rst-class:: classref-property
  73. :ref:`bool<class_bool>` **enabled** = ``true`` :ref:`🔗<class_TranslationDomain_property_enabled>`
  74. .. rst-class:: classref-property-setget
  75. - |void| **set_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  76. - :ref:`bool<class_bool>` **is_enabled**\ (\ )
  77. If ``true``, translation is enabled. Otherwise, :ref:`translate()<class_TranslationDomain_method_translate>` and :ref:`translate_plural()<class_TranslationDomain_method_translate_plural>` will return the input message unchanged regardless of the current locale.
  78. .. rst-class:: classref-item-separator
  79. ----
  80. .. _class_TranslationDomain_property_pseudolocalization_accents_enabled:
  81. .. rst-class:: classref-property
  82. :ref:`bool<class_bool>` **pseudolocalization_accents_enabled** = ``true`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_accents_enabled>`
  83. .. rst-class:: classref-property-setget
  84. - |void| **set_pseudolocalization_accents_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  85. - :ref:`bool<class_bool>` **is_pseudolocalization_accents_enabled**\ (\ )
  86. Replace all characters with their accented variants during pseudolocalization.
  87. \ **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.
  88. .. rst-class:: classref-item-separator
  89. ----
  90. .. _class_TranslationDomain_property_pseudolocalization_double_vowels_enabled:
  91. .. rst-class:: classref-property
  92. :ref:`bool<class_bool>` **pseudolocalization_double_vowels_enabled** = ``false`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_double_vowels_enabled>`
  93. .. rst-class:: classref-property-setget
  94. - |void| **set_pseudolocalization_double_vowels_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  95. - :ref:`bool<class_bool>` **is_pseudolocalization_double_vowels_enabled**\ (\ )
  96. Double vowels in strings during pseudolocalization to simulate the lengthening of text due to localization.
  97. \ **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.
  98. .. rst-class:: classref-item-separator
  99. ----
  100. .. _class_TranslationDomain_property_pseudolocalization_enabled:
  101. .. rst-class:: classref-property
  102. :ref:`bool<class_bool>` **pseudolocalization_enabled** = ``false`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_enabled>`
  103. .. rst-class:: classref-property-setget
  104. - |void| **set_pseudolocalization_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  105. - :ref:`bool<class_bool>` **is_pseudolocalization_enabled**\ (\ )
  106. 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.
  107. \ **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.
  108. .. rst-class:: classref-item-separator
  109. ----
  110. .. _class_TranslationDomain_property_pseudolocalization_expansion_ratio:
  111. .. rst-class:: classref-property
  112. :ref:`float<class_float>` **pseudolocalization_expansion_ratio** = ``0.0`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_expansion_ratio>`
  113. .. rst-class:: classref-property-setget
  114. - |void| **set_pseudolocalization_expansion_ratio**\ (\ value\: :ref:`float<class_float>`\ )
  115. - :ref:`float<class_float>` **get_pseudolocalization_expansion_ratio**\ (\ )
  116. 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%.
  117. \ **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.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_TranslationDomain_property_pseudolocalization_fake_bidi_enabled:
  121. .. rst-class:: classref-property
  122. :ref:`bool<class_bool>` **pseudolocalization_fake_bidi_enabled** = ``false`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_fake_bidi_enabled>`
  123. .. rst-class:: classref-property-setget
  124. - |void| **set_pseudolocalization_fake_bidi_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  125. - :ref:`bool<class_bool>` **is_pseudolocalization_fake_bidi_enabled**\ (\ )
  126. 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.
  127. \ **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.
  128. .. rst-class:: classref-item-separator
  129. ----
  130. .. _class_TranslationDomain_property_pseudolocalization_override_enabled:
  131. .. rst-class:: classref-property
  132. :ref:`bool<class_bool>` **pseudolocalization_override_enabled** = ``false`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_override_enabled>`
  133. .. rst-class:: classref-property-setget
  134. - |void| **set_pseudolocalization_override_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  135. - :ref:`bool<class_bool>` **is_pseudolocalization_override_enabled**\ (\ )
  136. Replace all characters in the string with ``*``. Useful for finding non-localizable strings.
  137. \ **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.
  138. .. rst-class:: classref-item-separator
  139. ----
  140. .. _class_TranslationDomain_property_pseudolocalization_prefix:
  141. .. rst-class:: classref-property
  142. :ref:`String<class_String>` **pseudolocalization_prefix** = ``"["`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_prefix>`
  143. .. rst-class:: classref-property-setget
  144. - |void| **set_pseudolocalization_prefix**\ (\ value\: :ref:`String<class_String>`\ )
  145. - :ref:`String<class_String>` **get_pseudolocalization_prefix**\ (\ )
  146. Prefix that will be prepended to the pseudolocalized string.
  147. \ **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.
  148. .. rst-class:: classref-item-separator
  149. ----
  150. .. _class_TranslationDomain_property_pseudolocalization_skip_placeholders_enabled:
  151. .. rst-class:: classref-property
  152. :ref:`bool<class_bool>` **pseudolocalization_skip_placeholders_enabled** = ``true`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_skip_placeholders_enabled>`
  153. .. rst-class:: classref-property-setget
  154. - |void| **set_pseudolocalization_skip_placeholders_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
  155. - :ref:`bool<class_bool>` **is_pseudolocalization_skip_placeholders_enabled**\ (\ )
  156. Skip placeholders for string formatting like ``%s`` or ``%f`` during pseudolocalization. Useful to identify strings which need additional control characters to display correctly.
  157. \ **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.
  158. .. rst-class:: classref-item-separator
  159. ----
  160. .. _class_TranslationDomain_property_pseudolocalization_suffix:
  161. .. rst-class:: classref-property
  162. :ref:`String<class_String>` **pseudolocalization_suffix** = ``"]"`` :ref:`🔗<class_TranslationDomain_property_pseudolocalization_suffix>`
  163. .. rst-class:: classref-property-setget
  164. - |void| **set_pseudolocalization_suffix**\ (\ value\: :ref:`String<class_String>`\ )
  165. - :ref:`String<class_String>` **get_pseudolocalization_suffix**\ (\ )
  166. Suffix that will be appended to the pseudolocalized string.
  167. \ **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.
  168. .. rst-class:: classref-section-separator
  169. ----
  170. .. rst-class:: classref-descriptions-group
  171. Method Descriptions
  172. -------------------
  173. .. _class_TranslationDomain_method_add_translation:
  174. .. rst-class:: classref-method
  175. |void| **add_translation**\ (\ translation\: :ref:`Translation<class_Translation>`\ ) :ref:`🔗<class_TranslationDomain_method_add_translation>`
  176. Adds a translation.
  177. .. rst-class:: classref-item-separator
  178. ----
  179. .. _class_TranslationDomain_method_clear:
  180. .. rst-class:: classref-method
  181. |void| **clear**\ (\ ) :ref:`🔗<class_TranslationDomain_method_clear>`
  182. Removes all translations.
  183. .. rst-class:: classref-item-separator
  184. ----
  185. .. _class_TranslationDomain_method_get_locale_override:
  186. .. rst-class:: classref-method
  187. :ref:`String<class_String>` **get_locale_override**\ (\ ) |const| :ref:`🔗<class_TranslationDomain_method_get_locale_override>`
  188. Returns the locale override of the domain. Returns an empty string if locale override is disabled.
  189. .. rst-class:: classref-item-separator
  190. ----
  191. .. _class_TranslationDomain_method_get_translation_object:
  192. .. rst-class:: classref-method
  193. :ref:`Translation<class_Translation>` **get_translation_object**\ (\ locale\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_TranslationDomain_method_get_translation_object>`
  194. Returns the :ref:`Translation<class_Translation>` instance that best matches ``locale``. Returns ``null`` if there are no matches.
  195. .. rst-class:: classref-item-separator
  196. ----
  197. .. _class_TranslationDomain_method_pseudolocalize:
  198. .. rst-class:: classref-method
  199. :ref:`StringName<class_StringName>` **pseudolocalize**\ (\ message\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_TranslationDomain_method_pseudolocalize>`
  200. Returns the pseudolocalized string based on the ``message`` passed in.
  201. .. rst-class:: classref-item-separator
  202. ----
  203. .. _class_TranslationDomain_method_remove_translation:
  204. .. rst-class:: classref-method
  205. |void| **remove_translation**\ (\ translation\: :ref:`Translation<class_Translation>`\ ) :ref:`🔗<class_TranslationDomain_method_remove_translation>`
  206. Removes the given translation.
  207. .. rst-class:: classref-item-separator
  208. ----
  209. .. _class_TranslationDomain_method_set_locale_override:
  210. .. rst-class:: classref-method
  211. |void| **set_locale_override**\ (\ locale\: :ref:`String<class_String>`\ ) :ref:`🔗<class_TranslationDomain_method_set_locale_override>`
  212. Sets the locale override of the domain.
  213. If ``locale`` is an empty string, locale override is disabled. Otherwise, ``locale`` will be standardized to match known locales (e.g. ``en-US`` would be matched to ``en_US``).
  214. \ **Note:** Calling this method does not automatically update texts in the scene tree. Please propagate the :ref:`MainLoop.NOTIFICATION_TRANSLATION_CHANGED<class_MainLoop_constant_NOTIFICATION_TRANSLATION_CHANGED>` signal manually.
  215. .. rst-class:: classref-item-separator
  216. ----
  217. .. _class_TranslationDomain_method_translate:
  218. .. rst-class:: classref-method
  219. :ref:`StringName<class_StringName>` **translate**\ (\ message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_TranslationDomain_method_translate>`
  220. Returns the current locale's translation for the given message and context.
  221. .. rst-class:: classref-item-separator
  222. ----
  223. .. _class_TranslationDomain_method_translate_plural:
  224. .. rst-class:: classref-method
  225. :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>`
  226. Returns the current locale's translation for the given message, plural message and context.
  227. 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.
  228. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  229. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  230. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  231. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  232. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  233. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  234. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  235. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  236. .. |void| replace:: :abbr:`void (No return value.)`