classref: Sync with current master branch (f87858a8f)

This commit is contained in:
Yuri Sizov
2022-12-05 20:38:58 +03:00
parent 913ff5e602
commit a7745c4cc4
843 changed files with 158186 additions and 80821 deletions

View File

@@ -14,11 +14,15 @@ TranslationServer
Server that manages all translations.
.. rst-class:: classref-introduction-group
Description
-----------
Server that manages all translations. Translations can be set to it and removed from it.
.. rst-class:: classref-introduction-group
Tutorials
---------
@@ -26,251 +30,354 @@ Tutorials
- :doc:`Locales <../tutorials/i18n/locales>`
.. rst-class:: classref-reftable-group
Properties
----------
+-------------------------+------------------------------------------------------------------------------------------------+-----------+
| :ref:`bool<class_bool>` | :ref:`pseudolocalization_enabled<class_TranslationServer_property_pseudolocalization_enabled>` | ``false`` |
+-------------------------+------------------------------------------------------------------------------------------------+-----------+
.. table::
:widths: auto
+-------------------------+------------------------------------------------------------------------------------------------+-----------+
| :ref:`bool<class_bool>` | :ref:`pseudolocalization_enabled<class_TranslationServer_property_pseudolocalization_enabled>` | ``false`` |
+-------------------------+------------------------------------------------------------------------------------------------+-----------+
.. rst-class:: classref-reftable-group
Methods
-------
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_translation<class_TranslationServer_method_add_translation>` **(** :ref:`Translation<class_Translation>` translation **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`clear<class_TranslationServer_method_clear>` **(** **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :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| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_all_countries<class_TranslationServer_method_get_all_countries>` **(** **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_all_languages<class_TranslationServer_method_get_all_languages>` **(** **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_all_scripts<class_TranslationServer_method_get_all_scripts>` **(** **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_country_name<class_TranslationServer_method_get_country_name>` **(** :ref:`String<class_String>` country **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_language_name<class_TranslationServer_method_get_language_name>` **(** :ref:`String<class_String>` language **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_loaded_locales<class_TranslationServer_method_get_loaded_locales>` **(** **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_locale<class_TranslationServer_method_get_locale>` **(** **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_locale_name<class_TranslationServer_method_get_locale_name>` **(** :ref:`String<class_String>` locale **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_script_name<class_TranslationServer_method_get_script_name>` **(** :ref:`String<class_String>` script **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_tool_locale<class_TranslationServer_method_get_tool_locale>` **(** **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Translation<class_Translation>` | :ref:`get_translation_object<class_TranslationServer_method_get_translation_object>` **(** :ref:`String<class_String>` locale **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`StringName<class_StringName>` | :ref:`pseudolocalize<class_TranslationServer_method_pseudolocalize>` **(** :ref:`StringName<class_StringName>` message **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`reload_pseudolocalization<class_TranslationServer_method_reload_pseudolocalization>` **(** **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`remove_translation<class_TranslationServer_method_remove_translation>` **(** :ref:`Translation<class_Translation>` translation **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_locale<class_TranslationServer_method_set_locale>` **(** :ref:`String<class_String>` locale **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`standardize_locale<class_TranslationServer_method_standardize_locale>` **(** :ref:`String<class_String>` locale **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`StringName<class_StringName>` | :ref:`translate<class_TranslationServer_method_translate>` **(** :ref:`StringName<class_StringName>` message, :ref:`StringName<class_StringName>` context="" **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`StringName<class_StringName>` | :ref:`translate_plural<class_TranslationServer_method_translate_plural>` **(** :ref:`StringName<class_StringName>` message, :ref:`StringName<class_StringName>` plural_message, :ref:`int<class_int>` n, :ref:`StringName<class_StringName>` context="" **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. table::
:widths: auto
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`add_translation<class_TranslationServer_method_add_translation>` **(** :ref:`Translation<class_Translation>` translation **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`clear<class_TranslationServer_method_clear>` **(** **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :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| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_all_countries<class_TranslationServer_method_get_all_countries>` **(** **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_all_languages<class_TranslationServer_method_get_all_languages>` **(** **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_all_scripts<class_TranslationServer_method_get_all_scripts>` **(** **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_country_name<class_TranslationServer_method_get_country_name>` **(** :ref:`String<class_String>` country **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_language_name<class_TranslationServer_method_get_language_name>` **(** :ref:`String<class_String>` language **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_loaded_locales<class_TranslationServer_method_get_loaded_locales>` **(** **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_locale<class_TranslationServer_method_get_locale>` **(** **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_locale_name<class_TranslationServer_method_get_locale_name>` **(** :ref:`String<class_String>` locale **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_script_name<class_TranslationServer_method_get_script_name>` **(** :ref:`String<class_String>` script **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`get_tool_locale<class_TranslationServer_method_get_tool_locale>` **(** **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Translation<class_Translation>` | :ref:`get_translation_object<class_TranslationServer_method_get_translation_object>` **(** :ref:`String<class_String>` locale **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`StringName<class_StringName>` | :ref:`pseudolocalize<class_TranslationServer_method_pseudolocalize>` **(** :ref:`StringName<class_StringName>` message **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`reload_pseudolocalization<class_TranslationServer_method_reload_pseudolocalization>` **(** **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`remove_translation<class_TranslationServer_method_remove_translation>` **(** :ref:`Translation<class_Translation>` translation **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_locale<class_TranslationServer_method_set_locale>` **(** :ref:`String<class_String>` locale **)** |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`standardize_locale<class_TranslationServer_method_standardize_locale>` **(** :ref:`String<class_String>` locale **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`StringName<class_StringName>` | :ref:`translate<class_TranslationServer_method_translate>` **(** :ref:`StringName<class_StringName>` message, :ref:`StringName<class_StringName>` context="" **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`StringName<class_StringName>` | :ref:`translate_plural<class_TranslationServer_method_translate_plural>` **(** :ref:`StringName<class_StringName>` message, :ref:`StringName<class_StringName>` plural_message, :ref:`int<class_int>` n, :ref:`StringName<class_StringName>` context="" **)** |const| |
+---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Property Descriptions
---------------------
.. _class_TranslationServer_property_pseudolocalization_enabled:
- :ref:`bool<class_bool>` **pseudolocalization_enabled**
.. rst-class:: classref-property
+-----------+---------------------------------------+
| *Default* | ``false`` |
+-----------+---------------------------------------+
| *Setter* | set_pseudolocalization_enabled(value) |
+-----------+---------------------------------------+
| *Getter* | is_pseudolocalization_enabled() |
+-----------+---------------------------------------+
:ref:`bool<class_bool>` **pseudolocalization_enabled** = ``false``
.. rst-class:: classref-property-setget
- void **set_pseudolocalization_enabled** **(** :ref:`bool<class_bool>` value **)**
- :ref:`bool<class_bool>` **is_pseudolocalization_enabled** **(** **)**
If ``true``, enables the use of pseudolocalization. See :ref:`ProjectSettings.internationalization/pseudolocalization/use_pseudolocalization<class_ProjectSettings_property_internationalization/pseudolocalization/use_pseudolocalization>` for details.
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
Method Descriptions
-------------------
.. _class_TranslationServer_method_add_translation:
- void **add_translation** **(** :ref:`Translation<class_Translation>` translation **)**
.. rst-class:: classref-method
void **add_translation** **(** :ref:`Translation<class_Translation>` translation **)**
Adds a :ref:`Translation<class_Translation>` resource.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_clear:
- void **clear** **(** **)**
.. rst-class:: classref-method
void **clear** **(** **)**
Clears the server from all translations.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_compare_locales:
- :ref:`int<class_int>` **compare_locales** **(** :ref:`String<class_String>` locale_a, :ref:`String<class_String>` locale_b **)** |const|
.. rst-class:: classref-method
:ref:`int<class_int>` **compare_locales** **(** :ref:`String<class_String>` locale_a, :ref:`String<class_String>` locale_b **)** |const|
Compares two locales and return similarity score between ``0``\ (no match) and ``10``\ (full match).
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_get_all_countries:
- :ref:`PackedStringArray<class_PackedStringArray>` **get_all_countries** **(** **)** |const|
.. rst-class:: classref-method
:ref:`PackedStringArray<class_PackedStringArray>` **get_all_countries** **(** **)** |const|
Returns array of known country codes.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_get_all_languages:
- :ref:`PackedStringArray<class_PackedStringArray>` **get_all_languages** **(** **)** |const|
.. rst-class:: classref-method
:ref:`PackedStringArray<class_PackedStringArray>` **get_all_languages** **(** **)** |const|
Returns array of known language codes.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_get_all_scripts:
- :ref:`PackedStringArray<class_PackedStringArray>` **get_all_scripts** **(** **)** |const|
.. rst-class:: classref-method
:ref:`PackedStringArray<class_PackedStringArray>` **get_all_scripts** **(** **)** |const|
Returns array of known script codes.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_get_country_name:
- :ref:`String<class_String>` **get_country_name** **(** :ref:`String<class_String>` country **)** |const|
.. rst-class:: classref-method
:ref:`String<class_String>` **get_country_name** **(** :ref:`String<class_String>` country **)** |const|
Returns readable country name for the ``country`` code.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_get_language_name:
- :ref:`String<class_String>` **get_language_name** **(** :ref:`String<class_String>` language **)** |const|
.. rst-class:: classref-method
:ref:`String<class_String>` **get_language_name** **(** :ref:`String<class_String>` language **)** |const|
Returns readable language name for the ``language`` code.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_get_loaded_locales:
- :ref:`PackedStringArray<class_PackedStringArray>` **get_loaded_locales** **(** **)** |const|
.. rst-class:: classref-method
:ref:`PackedStringArray<class_PackedStringArray>` **get_loaded_locales** **(** **)** |const|
Returns an array of all loaded locales of the project.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_get_locale:
- :ref:`String<class_String>` **get_locale** **(** **)** |const|
.. rst-class:: classref-method
:ref:`String<class_String>` **get_locale** **(** **)** |const|
Returns the current locale of the project.
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.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_get_locale_name:
- :ref:`String<class_String>` **get_locale_name** **(** :ref:`String<class_String>` locale **)** |const|
.. rst-class:: classref-method
:ref:`String<class_String>` **get_locale_name** **(** :ref:`String<class_String>` locale **)** |const|
Returns a locale's language and its variant (e.g. ``"en_US"`` would return ``"English (United States)"``).
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_get_script_name:
- :ref:`String<class_String>` **get_script_name** **(** :ref:`String<class_String>` script **)** |const|
.. rst-class:: classref-method
:ref:`String<class_String>` **get_script_name** **(** :ref:`String<class_String>` script **)** |const|
Returns readable script name for the ``script`` code.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_get_tool_locale:
- :ref:`String<class_String>` **get_tool_locale** **(** **)**
.. rst-class:: classref-method
:ref:`String<class_String>` **get_tool_locale** **(** **)**
Returns the current locale of the editor.
\ **Note:** When called from an exported project returns the same value as :ref:`get_locale<class_TranslationServer_method_get_locale>`.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_get_translation_object:
- :ref:`Translation<class_Translation>` **get_translation_object** **(** :ref:`String<class_String>` locale **)**
.. rst-class:: classref-method
:ref:`Translation<class_Translation>` **get_translation_object** **(** :ref:`String<class_String>` locale **)**
Returns the :ref:`Translation<class_Translation>` instance based on the ``locale`` passed in.
It will return ``null`` if there is no :ref:`Translation<class_Translation>` instance that matches the ``locale``.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_pseudolocalize:
- :ref:`StringName<class_StringName>` **pseudolocalize** **(** :ref:`StringName<class_StringName>` message **)** |const|
.. rst-class:: classref-method
:ref:`StringName<class_StringName>` **pseudolocalize** **(** :ref:`StringName<class_StringName>` message **)** |const|
Returns the pseudolocalized string based on the ``message`` passed in.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_reload_pseudolocalization:
- void **reload_pseudolocalization** **(** **)**
.. rst-class:: classref-method
void **reload_pseudolocalization** **(** **)**
Reparses the pseudolocalization options and reloads the translation.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_remove_translation:
- void **remove_translation** **(** :ref:`Translation<class_Translation>` translation **)**
.. rst-class:: classref-method
void **remove_translation** **(** :ref:`Translation<class_Translation>` translation **)**
Removes the given translation from the server.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_set_locale:
- void **set_locale** **(** :ref:`String<class_String>` locale **)**
.. rst-class:: classref-method
void **set_locale** **(** :ref:`String<class_String>` locale **)**
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``).
If translations have been loaded beforehand for the new locale, they will be applied.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_standardize_locale:
- :ref:`String<class_String>` **standardize_locale** **(** :ref:`String<class_String>` locale **)** |const|
.. rst-class:: classref-method
:ref:`String<class_String>` **standardize_locale** **(** :ref:`String<class_String>` locale **)** |const|
Returns ``locale`` string standardized to match known locales (e.g. ``en-US`` would be matched to ``en_US``).
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_translate:
- :ref:`StringName<class_StringName>` **translate** **(** :ref:`StringName<class_StringName>` message, :ref:`StringName<class_StringName>` context="" **)** |const|
.. rst-class:: classref-method
:ref:`StringName<class_StringName>` **translate** **(** :ref:`StringName<class_StringName>` message, :ref:`StringName<class_StringName>` context="" **)** |const|
Returns the current locale's translation for the given message (key) and context.
.. rst-class:: classref-item-separator
----
.. _class_TranslationServer_method_translate_plural:
- :ref:`StringName<class_StringName>` **translate_plural** **(** :ref:`StringName<class_StringName>` message, :ref:`StringName<class_StringName>` plural_message, :ref:`int<class_int>` n, :ref:`StringName<class_StringName>` context="" **)** |const|
.. rst-class:: classref-method
:ref:`StringName<class_StringName>` **translate_plural** **(** :ref:`StringName<class_StringName>` message, :ref:`StringName<class_StringName>` plural_message, :ref:`int<class_int>` n, :ref:`StringName<class_StringName>` context="" **)** |const|
Returns the current locale's translation for the given message (key), plural_message and context.