class_translation.rst 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. Language Translation.
  12. Description
  13. -----------
  14. Translations are resources that can be loaded and unloaded on demand. They map a string to another string.
  15. Tutorials
  16. ---------
  17. - :doc:`Internationalizing games <../tutorials/i18n/internationalizing_games>`
  18. - :doc:`Locales <../tutorials/i18n/locales>`
  19. Properties
  20. ----------
  21. +-----------------------------+--------------------------------------------------+----------+
  22. | :ref:`String<class_String>` | :ref:`locale<class_Translation_property_locale>` | ``"en"`` |
  23. +-----------------------------+--------------------------------------------------+----------+
  24. Methods
  25. -------
  26. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`StringName<class_StringName>` | :ref:`_get_message<class_Translation_method__get_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` context **)** |virtual| |const| |
  28. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`StringName<class_StringName>` | :ref:`_get_plural_message<class_Translation_method__get_plural_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` src_plural_message, :ref:`int<class_int>` n, :ref:`StringName<class_StringName>` context **)** |virtual| |const| |
  30. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  31. | void | :ref:`add_message<class_Translation_method_add_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` xlated_message, :ref:`StringName<class_StringName>` context="" **)** |
  32. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  33. | void | :ref:`add_plural_message<class_Translation_method_add_plural_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`PackedStringArray<class_PackedStringArray>` xlated_messages, :ref:`StringName<class_StringName>` context="" **)** |
  34. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`erase_message<class_Translation_method_erase_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` context="" **)** |
  36. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`StringName<class_StringName>` | :ref:`get_message<class_Translation_method_get_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` context="" **)** |const| |
  38. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`int<class_int>` | :ref:`get_message_count<class_Translation_method_get_message_count>` **(** **)** |const| |
  40. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_message_list<class_Translation_method_get_message_list>` **(** **)** |const| |
  42. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`StringName<class_StringName>` | :ref:`get_plural_message<class_Translation_method_get_plural_message>` **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` src_plural_message, :ref:`int<class_int>` n, :ref:`StringName<class_StringName>` context="" **)** |const| |
  44. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. Property Descriptions
  46. ---------------------
  47. .. _class_Translation_property_locale:
  48. - :ref:`String<class_String>` **locale**
  49. +-----------+-------------------+
  50. | *Default* | ``"en"`` |
  51. +-----------+-------------------+
  52. | *Setter* | set_locale(value) |
  53. +-----------+-------------------+
  54. | *Getter* | get_locale() |
  55. +-----------+-------------------+
  56. The locale of the translation.
  57. Method Descriptions
  58. -------------------
  59. .. _class_Translation_method__get_message:
  60. - :ref:`StringName<class_StringName>` **_get_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` context **)** |virtual| |const|
  61. Virtual method to override :ref:`get_message<class_Translation_method_get_message>`.
  62. ----
  63. .. _class_Translation_method__get_plural_message:
  64. - :ref:`StringName<class_StringName>` **_get_plural_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` src_plural_message, :ref:`int<class_int>` n, :ref:`StringName<class_StringName>` context **)** |virtual| |const|
  65. Virtual method to override :ref:`get_plural_message<class_Translation_method_get_plural_message>`.
  66. ----
  67. .. _class_Translation_method_add_message:
  68. - void **add_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` xlated_message, :ref:`StringName<class_StringName>` context="" **)**
  69. Adds a message if nonexistent, followed by its translation.
  70. An additional context could be used to specify the translation context or differentiate polysemic words.
  71. ----
  72. .. _class_Translation_method_add_plural_message:
  73. - void **add_plural_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`PackedStringArray<class_PackedStringArray>` xlated_messages, :ref:`StringName<class_StringName>` context="" **)**
  74. Adds a message involving plural translation if nonexistent, followed by its translation.
  75. An additional context could be used to specify the translation context or differentiate polysemic words.
  76. ----
  77. .. _class_Translation_method_erase_message:
  78. - void **erase_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` context="" **)**
  79. Erases a message.
  80. ----
  81. .. _class_Translation_method_get_message:
  82. - :ref:`StringName<class_StringName>` **get_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` context="" **)** |const|
  83. Returns a message's translation.
  84. ----
  85. .. _class_Translation_method_get_message_count:
  86. - :ref:`int<class_int>` **get_message_count** **(** **)** |const|
  87. Returns the number of existing messages.
  88. ----
  89. .. _class_Translation_method_get_message_list:
  90. - :ref:`PackedStringArray<class_PackedStringArray>` **get_message_list** **(** **)** |const|
  91. Returns all the messages (keys).
  92. ----
  93. .. _class_Translation_method_get_plural_message:
  94. - :ref:`StringName<class_StringName>` **get_plural_message** **(** :ref:`StringName<class_StringName>` src_message, :ref:`StringName<class_StringName>` src_plural_message, :ref:`int<class_int>` n, :ref:`StringName<class_StringName>` context="" **)** |const|
  95. Returns a message's translation involving plurals.
  96. 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.
  97. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  98. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  99. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  100. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  101. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  102. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`