class_translationserver.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/TranslationServer.xml.
  6. .. _class_TranslationServer:
  7. TranslationServer
  8. =================
  9. **Inherits:** :ref:`Object<class_Object>`
  10. Server that manages all translations.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Server that manages all translations. Translations can be set to it and removed from it.
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - :doc:`../tutorials/i18n/internationalizing_games`
  19. - :doc:`../tutorials/i18n/locales`
  20. .. rst-class:: classref-reftable-group
  21. Methods
  22. -------
  23. .. table::
  24. :widths: auto
  25. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | void | :ref:`add_translation<class_TranslationServer_method_add_translation>` **(** :ref:`Translation<class_Translation>` translation **)** |
  27. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | void | :ref:`clear<class_TranslationServer_method_clear>` **(** **)** |
  29. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`int<class_int>` | :ref:`compare_locales<class_TranslationServer_method_compare_locales>` **(** :ref:`String<class_String>` locale_a, :ref:`String<class_String>` locale_b **)** |const| |
  31. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_all_countries<class_TranslationServer_method_get_all_countries>` **(** **)** |const| |
  33. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_all_languages<class_TranslationServer_method_get_all_languages>` **(** **)** |const| |
  35. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`PoolStringArray<class_PoolStringArray>` | :ref:`get_all_scripts<class_TranslationServer_method_get_all_scripts>` **(** **)** |const| |
  37. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`String<class_String>` | :ref:`get_country_name<class_TranslationServer_method_get_country_name>` **(** :ref:`String<class_String>` country **)** |const| |
  39. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`String<class_String>` | :ref:`get_language_name<class_TranslationServer_method_get_language_name>` **(** :ref:`String<class_String>` language **)** |const| |
  41. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Array<class_Array>` | :ref:`get_loaded_locales<class_TranslationServer_method_get_loaded_locales>` **(** **)** |const| |
  43. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`String<class_String>` | :ref:`get_locale<class_TranslationServer_method_get_locale>` **(** **)** |const| |
  45. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`String<class_String>` | :ref:`get_locale_name<class_TranslationServer_method_get_locale_name>` **(** :ref:`String<class_String>` locale **)** |const| |
  47. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`String<class_String>` | :ref:`get_script_name<class_TranslationServer_method_get_script_name>` **(** :ref:`String<class_String>` script **)** |const| |
  49. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`remove_translation<class_TranslationServer_method_remove_translation>` **(** :ref:`Translation<class_Translation>` translation **)** |
  51. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`set_locale<class_TranslationServer_method_set_locale>` **(** :ref:`String<class_String>` locale **)** |
  53. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`String<class_String>` | :ref:`standardize_locale<class_TranslationServer_method_standardize_locale>` **(** :ref:`String<class_String>` locale **)** |const| |
  55. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`String<class_String>` | :ref:`translate<class_TranslationServer_method_translate>` **(** :ref:`String<class_String>` message **)** |const| |
  57. +-----------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. .. rst-class:: classref-section-separator
  59. ----
  60. .. rst-class:: classref-descriptions-group
  61. Method Descriptions
  62. -------------------
  63. .. _class_TranslationServer_method_add_translation:
  64. .. rst-class:: classref-method
  65. void **add_translation** **(** :ref:`Translation<class_Translation>` translation **)**
  66. Adds a :ref:`Translation<class_Translation>` resource.
  67. .. rst-class:: classref-item-separator
  68. ----
  69. .. _class_TranslationServer_method_clear:
  70. .. rst-class:: classref-method
  71. void **clear** **(** **)**
  72. Clears the server from all translations.
  73. .. rst-class:: classref-item-separator
  74. ----
  75. .. _class_TranslationServer_method_compare_locales:
  76. .. rst-class:: classref-method
  77. :ref:`int<class_int>` **compare_locales** **(** :ref:`String<class_String>` locale_a, :ref:`String<class_String>` locale_b **)** |const|
  78. Compares two locales and return similarity score between ``0``\ (no match) and ``10``\ (full match).
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_TranslationServer_method_get_all_countries:
  82. .. rst-class:: classref-method
  83. :ref:`PoolStringArray<class_PoolStringArray>` **get_all_countries** **(** **)** |const|
  84. Returns array of known country codes.
  85. .. rst-class:: classref-item-separator
  86. ----
  87. .. _class_TranslationServer_method_get_all_languages:
  88. .. rst-class:: classref-method
  89. :ref:`PoolStringArray<class_PoolStringArray>` **get_all_languages** **(** **)** |const|
  90. Returns array of known language codes.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_TranslationServer_method_get_all_scripts:
  94. .. rst-class:: classref-method
  95. :ref:`PoolStringArray<class_PoolStringArray>` **get_all_scripts** **(** **)** |const|
  96. Returns array of known script codes.
  97. .. rst-class:: classref-item-separator
  98. ----
  99. .. _class_TranslationServer_method_get_country_name:
  100. .. rst-class:: classref-method
  101. :ref:`String<class_String>` **get_country_name** **(** :ref:`String<class_String>` country **)** |const|
  102. Returns readable country name for the ``country`` code.
  103. .. rst-class:: classref-item-separator
  104. ----
  105. .. _class_TranslationServer_method_get_language_name:
  106. .. rst-class:: classref-method
  107. :ref:`String<class_String>` **get_language_name** **(** :ref:`String<class_String>` language **)** |const|
  108. Returns readable language name for the ``language`` code.
  109. .. rst-class:: classref-item-separator
  110. ----
  111. .. _class_TranslationServer_method_get_loaded_locales:
  112. .. rst-class:: classref-method
  113. :ref:`Array<class_Array>` **get_loaded_locales** **(** **)** |const|
  114. Returns an array of all loaded locales of the project.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_TranslationServer_method_get_locale:
  118. .. rst-class:: classref-method
  119. :ref:`String<class_String>` **get_locale** **(** **)** |const|
  120. Returns the current locale of the project.
  121. See also :ref:`OS.get_locale<class_OS_method_get_locale>` and :ref:`OS.get_locale_language<class_OS_method_get_locale_language>` to query the locale of the user system.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_TranslationServer_method_get_locale_name:
  125. .. rst-class:: classref-method
  126. :ref:`String<class_String>` **get_locale_name** **(** :ref:`String<class_String>` locale **)** |const|
  127. Returns a locale's language and its variant (e.g. ``"en_US"`` would return ``"English (United States)"``).
  128. .. rst-class:: classref-item-separator
  129. ----
  130. .. _class_TranslationServer_method_get_script_name:
  131. .. rst-class:: classref-method
  132. :ref:`String<class_String>` **get_script_name** **(** :ref:`String<class_String>` script **)** |const|
  133. Returns readable script name for the ``script`` code.
  134. .. rst-class:: classref-item-separator
  135. ----
  136. .. _class_TranslationServer_method_remove_translation:
  137. .. rst-class:: classref-method
  138. void **remove_translation** **(** :ref:`Translation<class_Translation>` translation **)**
  139. Removes the given translation from the server.
  140. .. rst-class:: classref-item-separator
  141. ----
  142. .. _class_TranslationServer_method_set_locale:
  143. .. rst-class:: classref-method
  144. void **set_locale** **(** :ref:`String<class_String>` locale **)**
  145. Sets the locale of the project. The ``locale`` string will be standardized to match known locales (e.g. ``en-US`` would be matched to ``en_US``).
  146. If translations have been loaded beforehand for the new locale, they will be applied.
  147. .. rst-class:: classref-item-separator
  148. ----
  149. .. _class_TranslationServer_method_standardize_locale:
  150. .. rst-class:: classref-method
  151. :ref:`String<class_String>` **standardize_locale** **(** :ref:`String<class_String>` locale **)** |const|
  152. Returns ``locale`` string standardized to match known locales (e.g. ``en-US`` would be matched to ``en_US``).
  153. .. rst-class:: classref-item-separator
  154. ----
  155. .. _class_TranslationServer_method_translate:
  156. .. rst-class:: classref-method
  157. :ref:`String<class_String>` **translate** **(** :ref:`String<class_String>` message **)** |const|
  158. Returns the current locale's translation for the given message (key).
  159. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  160. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  161. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  162. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`