123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- :github_url: hide
- .. DO NOT EDIT THIS FILE!!!
- .. Generated automatically from Godot engine sources.
- .. Generator: https://github.com/godotengine/godot/tree/4.3/doc/tools/make_rst.py.
- .. XML source: https://github.com/godotengine/godot/tree/4.3/doc/classes/TranslationServer.xml.
- .. _class_TranslationServer:
- TranslationServer
- =================
- **Inherits:** :ref:`Object<class_Object>`
- The server responsible for language translations.
- .. rst-class:: classref-introduction-group
- Description
- -----------
- The server that manages all language translations. Translations can be added to or removed from it.
- .. rst-class:: classref-introduction-group
- Tutorials
- ---------
- - :doc:`Internationalizing games <../tutorials/i18n/internationalizing_games>`
- - :doc:`Locales <../tutorials/i18n/locales>`
- .. rst-class:: classref-reftable-group
- Properties
- ----------
- .. table::
- :widths: auto
- +-------------------------+------------------------------------------------------------------------------------------------+-----------+
- | :ref:`bool<class_bool>` | :ref:`pseudolocalization_enabled<class_TranslationServer_property_pseudolocalization_enabled>` | ``false`` |
- +-------------------------+------------------------------------------------------------------------------------------------+-----------+
- .. rst-class:: classref-reftable-group
- Methods
- -------
- .. table::
- :widths: auto
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`add_translation<class_TranslationServer_method_add_translation>`\ (\ translation\: :ref:`Translation<class_Translation>`\ ) |
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`clear<class_TranslationServer_method_clear>`\ (\ ) |
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`compare_locales<class_TranslationServer_method_compare_locales>`\ (\ locale_a\: :ref:`String<class_String>`, locale_b\: :ref:`String<class_String>`\ ) |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>`\ (\ country\: :ref:`String<class_String>`\ ) |const| |
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_language_name<class_TranslationServer_method_get_language_name>`\ (\ language\: :ref:`String<class_String>`\ ) |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>`\ (\ locale\: :ref:`String<class_String>`\ ) |const| |
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_script_name<class_TranslationServer_method_get_script_name>`\ (\ script\: :ref:`String<class_String>`\ ) |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>`\ (\ locale\: :ref:`String<class_String>`\ ) |
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`StringName<class_StringName>` | :ref:`pseudolocalize<class_TranslationServer_method_pseudolocalize>`\ (\ message\: :ref:`StringName<class_StringName>`\ ) |const| |
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`reload_pseudolocalization<class_TranslationServer_method_reload_pseudolocalization>`\ (\ ) |
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`remove_translation<class_TranslationServer_method_remove_translation>`\ (\ translation\: :ref:`Translation<class_Translation>`\ ) |
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`set_locale<class_TranslationServer_method_set_locale>`\ (\ locale\: :ref:`String<class_String>`\ ) |
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`standardize_locale<class_TranslationServer_method_standardize_locale>`\ (\ locale\: :ref:`String<class_String>`\ ) |const| |
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`StringName<class_StringName>` | :ref:`translate<class_TranslationServer_method_translate>`\ (\ message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`StringName<class_StringName>` | :ref:`translate_plural<class_TranslationServer_method_translate_plural>`\ (\ message\: :ref:`StringName<class_StringName>`, plural_message\: :ref:`StringName<class_StringName>`, n\: :ref:`int<class_int>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| |
- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Property Descriptions
- ---------------------
- .. _class_TranslationServer_property_pseudolocalization_enabled:
- .. rst-class:: classref-property
- :ref:`bool<class_bool>` **pseudolocalization_enabled** = ``false`` :ref:`🔗<class_TranslationServer_property_pseudolocalization_enabled>`
- .. rst-class:: classref-property-setget
- - |void| **set_pseudolocalization_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
- - :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:
- .. rst-class:: classref-method
- |void| **add_translation**\ (\ translation\: :ref:`Translation<class_Translation>`\ ) :ref:`🔗<class_TranslationServer_method_add_translation>`
- Adds a :ref:`Translation<class_Translation>` resource.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_clear:
- .. rst-class:: classref-method
- |void| **clear**\ (\ ) :ref:`🔗<class_TranslationServer_method_clear>`
- Clears the server from all translations.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_compare_locales:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **compare_locales**\ (\ locale_a\: :ref:`String<class_String>`, locale_b\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_TranslationServer_method_compare_locales>`
- Compares two locales and returns a similarity score between ``0`` (no match) and ``10`` (full match).
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_get_all_countries:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_all_countries**\ (\ ) |const| :ref:`🔗<class_TranslationServer_method_get_all_countries>`
- Returns an array of known country codes.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_get_all_languages:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_all_languages**\ (\ ) |const| :ref:`🔗<class_TranslationServer_method_get_all_languages>`
- Returns array of known language codes.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_get_all_scripts:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_all_scripts**\ (\ ) |const| :ref:`🔗<class_TranslationServer_method_get_all_scripts>`
- Returns an array of known script codes.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_get_country_name:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_country_name**\ (\ country\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_TranslationServer_method_get_country_name>`
- Returns a readable country name for the ``country`` code.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_get_language_name:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_language_name**\ (\ language\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_TranslationServer_method_get_language_name>`
- Returns a readable language name for the ``language`` code.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_get_loaded_locales:
- .. rst-class:: classref-method
- :ref:`PackedStringArray<class_PackedStringArray>` **get_loaded_locales**\ (\ ) |const| :ref:`🔗<class_TranslationServer_method_get_loaded_locales>`
- Returns an array of all loaded locales of the project.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_get_locale:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_locale**\ (\ ) |const| :ref:`🔗<class_TranslationServer_method_get_locale>`
- 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:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_locale_name**\ (\ locale\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_TranslationServer_method_get_locale_name>`
- 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:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_script_name**\ (\ script\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_TranslationServer_method_get_script_name>`
- Returns a readable script name for the ``script`` code.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_get_tool_locale:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_tool_locale**\ (\ ) :ref:`🔗<class_TranslationServer_method_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:
- .. rst-class:: classref-method
- :ref:`Translation<class_Translation>` **get_translation_object**\ (\ locale\: :ref:`String<class_String>`\ ) :ref:`🔗<class_TranslationServer_method_get_translation_object>`
- 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:
- .. rst-class:: classref-method
- :ref:`StringName<class_StringName>` **pseudolocalize**\ (\ message\: :ref:`StringName<class_StringName>`\ ) |const| :ref:`🔗<class_TranslationServer_method_pseudolocalize>`
- Returns the pseudolocalized string based on the ``message`` passed in.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_reload_pseudolocalization:
- .. rst-class:: classref-method
- |void| **reload_pseudolocalization**\ (\ ) :ref:`🔗<class_TranslationServer_method_reload_pseudolocalization>`
- Reparses the pseudolocalization options and reloads the translation.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_remove_translation:
- .. rst-class:: classref-method
- |void| **remove_translation**\ (\ translation\: :ref:`Translation<class_Translation>`\ ) :ref:`🔗<class_TranslationServer_method_remove_translation>`
- Removes the given translation from the server.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_set_locale:
- .. rst-class:: classref-method
- |void| **set_locale**\ (\ locale\: :ref:`String<class_String>`\ ) :ref:`🔗<class_TranslationServer_method_set_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:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **standardize_locale**\ (\ locale\: :ref:`String<class_String>`\ ) |const| :ref:`🔗<class_TranslationServer_method_standardize_locale>`
- Returns a ``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:
- .. rst-class:: classref-method
- :ref:`StringName<class_StringName>` **translate**\ (\ message\: :ref:`StringName<class_StringName>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_TranslationServer_method_translate>`
- Returns the current locale's translation for the given message (key) and context.
- .. rst-class:: classref-item-separator
- ----
- .. _class_TranslationServer_method_translate_plural:
- .. rst-class:: classref-method
- :ref:`StringName<class_StringName>` **translate_plural**\ (\ message\: :ref:`StringName<class_StringName>`, plural_message\: :ref:`StringName<class_StringName>`, n\: :ref:`int<class_int>`, context\: :ref:`StringName<class_StringName>` = &""\ ) |const| :ref:`🔗<class_TranslationServer_method_translate_plural>`
- Returns the current locale's translation for the given message (key), plural message and context.
- 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.
- .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
- .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
- .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
- .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
- .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
- .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
- .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
- .. |void| replace:: :abbr:`void (No return value.)`
|