class_translationserver.rst 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the TranslationServer.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_TranslationServer:
  6. TranslationServer
  7. =================
  8. **Inherits:** :ref:`Object<class_Object>`
  9. Server that manages all translations.
  10. Description
  11. -----------
  12. Server that manages all translations. Translations can be set to it and removed from it.
  13. Tutorials
  14. ---------
  15. - :doc:`../tutorials/i18n/internationalizing_games`
  16. - :doc:`../tutorials/i18n/locales`
  17. Methods
  18. -------
  19. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  20. | void | :ref:`add_translation<class_TranslationServer_method_add_translation>` **(** :ref:`Translation<class_Translation>` translation **)** |
  21. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  22. | void | :ref:`clear<class_TranslationServer_method_clear>` **(** **)** |
  23. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`Array<class_Array>` | :ref:`get_loaded_locales<class_TranslationServer_method_get_loaded_locales>` **(** **)** |const| |
  25. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`String<class_String>` | :ref:`get_locale<class_TranslationServer_method_get_locale>` **(** **)** |const| |
  27. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`String<class_String>` | :ref:`get_locale_name<class_TranslationServer_method_get_locale_name>` **(** :ref:`String<class_String>` locale **)** |const| |
  29. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  30. | void | :ref:`remove_translation<class_TranslationServer_method_remove_translation>` **(** :ref:`Translation<class_Translation>` translation **)** |
  31. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`set_locale<class_TranslationServer_method_set_locale>` **(** :ref:`String<class_String>` locale **)** |
  33. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`String<class_String>` | :ref:`translate<class_TranslationServer_method_translate>` **(** :ref:`String<class_String>` message **)** |const| |
  35. +-----------------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
  36. Method Descriptions
  37. -------------------
  38. .. _class_TranslationServer_method_add_translation:
  39. - void **add_translation** **(** :ref:`Translation<class_Translation>` translation **)**
  40. Adds a :ref:`Translation<class_Translation>` resource.
  41. ----
  42. .. _class_TranslationServer_method_clear:
  43. - void **clear** **(** **)**
  44. Clears the server from all translations.
  45. ----
  46. .. _class_TranslationServer_method_get_loaded_locales:
  47. - :ref:`Array<class_Array>` **get_loaded_locales** **(** **)** |const|
  48. Returns an array of all loaded locales of the project.
  49. ----
  50. .. _class_TranslationServer_method_get_locale:
  51. - :ref:`String<class_String>` **get_locale** **(** **)** |const|
  52. Returns the current locale of the project.
  53. 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.
  54. ----
  55. .. _class_TranslationServer_method_get_locale_name:
  56. - :ref:`String<class_String>` **get_locale_name** **(** :ref:`String<class_String>` locale **)** |const|
  57. Returns a locale's language and its variant (e.g. ``"en_US"`` would return ``"English (United States)"``).
  58. ----
  59. .. _class_TranslationServer_method_remove_translation:
  60. - void **remove_translation** **(** :ref:`Translation<class_Translation>` translation **)**
  61. Removes the given translation from the server.
  62. ----
  63. .. _class_TranslationServer_method_set_locale:
  64. - void **set_locale** **(** :ref:`String<class_String>` locale **)**
  65. 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``).
  66. If translations have been loaded beforehand for the new locale, they will be applied.
  67. ----
  68. .. _class_TranslationServer_method_translate:
  69. - :ref:`String<class_String>` **translate** **(** :ref:`String<class_String>` message **)** |const|
  70. Returns the current locale's translation for the given message (key).
  71. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  72. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  73. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`