:github_url: hide .. Generated automatically by doc/tools/make_rst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the TranslationServer.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_TranslationServer: TranslationServer ================= **Inherits:** :ref:`Object` Server that manages all translations. Description ----------- Server that manages all translations. Translations can be set to it and removed from it. Tutorials --------- - :doc:`Internationalizing games <../tutorials/i18n/internationalizing_games>` - :doc:`Locales <../tutorials/i18n/locales>` Properties ---------- +-------------------------+------------------------------------------------------------------------------------------------+-----------+ | :ref:`bool` | :ref:`pseudolocalization_enabled` | ``false`` | +-------------------------+------------------------------------------------------------------------------------------------+-----------+ Methods ------- +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`add_translation` **(** :ref:`Translation` translation **)** | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`clear` **(** **)** | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`compare_locales` **(** :ref:`String` locale_a, :ref:`String` locale_b **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedStringArray` | :ref:`get_all_countries` **(** **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedStringArray` | :ref:`get_all_languages` **(** **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedStringArray` | :ref:`get_all_scripts` **(** **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_country_name` **(** :ref:`String` country **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_language_name` **(** :ref:`String` language **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_loaded_locales` **(** **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_locale` **(** **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_locale_name` **(** :ref:`String` locale **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_script_name` **(** :ref:`String` script **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_tool_locale` **(** **)** | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Translation` | :ref:`get_translation_object` **(** :ref:`String` locale **)** | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`pseudolocalize` **(** :ref:`StringName` message **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`reload_pseudolocalization` **(** **)** | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`remove_translation` **(** :ref:`Translation` translation **)** | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | void | :ref:`set_locale` **(** :ref:`String` locale **)** | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`standardize_locale` **(** :ref:`String` locale **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`translate` **(** :ref:`StringName` message, :ref:`StringName` context="" **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`translate_plural` **(** :ref:`StringName` message, :ref:`StringName` plural_message, :ref:`int` n, :ref:`StringName` context="" **)** |const| | +---------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ Property Descriptions --------------------- .. _class_TranslationServer_property_pseudolocalization_enabled: - :ref:`bool` **pseudolocalization_enabled** +-----------+---------------------------------------+ | *Default* | ``false`` | +-----------+---------------------------------------+ | *Setter* | set_pseudolocalization_enabled(value) | +-----------+---------------------------------------+ | *Getter* | is_pseudolocalization_enabled() | +-----------+---------------------------------------+ If ``true``, enables the use of pseudolocalization. See :ref:`ProjectSettings.internationalization/pseudolocalization/use_pseudolocalization` for details. Method Descriptions ------------------- .. _class_TranslationServer_method_add_translation: - void **add_translation** **(** :ref:`Translation` translation **)** Adds a :ref:`Translation` resource. ---- .. _class_TranslationServer_method_clear: - void **clear** **(** **)** Clears the server from all translations. ---- .. _class_TranslationServer_method_compare_locales: - :ref:`int` **compare_locales** **(** :ref:`String` locale_a, :ref:`String` locale_b **)** |const| Compares two locales and return similarity score between ``0``\ (no match) and ``10``\ (full match). ---- .. _class_TranslationServer_method_get_all_countries: - :ref:`PackedStringArray` **get_all_countries** **(** **)** |const| Returns array of known country codes. ---- .. _class_TranslationServer_method_get_all_languages: - :ref:`PackedStringArray` **get_all_languages** **(** **)** |const| Returns array of known language codes. ---- .. _class_TranslationServer_method_get_all_scripts: - :ref:`PackedStringArray` **get_all_scripts** **(** **)** |const| Returns array of known script codes. ---- .. _class_TranslationServer_method_get_country_name: - :ref:`String` **get_country_name** **(** :ref:`String` country **)** |const| Returns readable country name for the ``country`` code. ---- .. _class_TranslationServer_method_get_language_name: - :ref:`String` **get_language_name** **(** :ref:`String` language **)** |const| Returns readable language name for the ``language`` code. ---- .. _class_TranslationServer_method_get_loaded_locales: - :ref:`Array` **get_loaded_locales** **(** **)** |const| Returns an array of all loaded locales of the project. ---- .. _class_TranslationServer_method_get_locale: - :ref:`String` **get_locale** **(** **)** |const| Returns the current locale of the project. See also :ref:`OS.get_locale` and :ref:`OS.get_locale_language` to query the locale of the user system. ---- .. _class_TranslationServer_method_get_locale_name: - :ref:`String` **get_locale_name** **(** :ref:`String` locale **)** |const| Returns a locale's language and its variant (e.g. ``"en_US"`` would return ``"English (United States)"``). ---- .. _class_TranslationServer_method_get_script_name: - :ref:`String` **get_script_name** **(** :ref:`String` script **)** |const| Returns readable script name for the ``script`` code. ---- .. _class_TranslationServer_method_get_tool_locale: - :ref:`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_translation_object: - :ref:`Translation` **get_translation_object** **(** :ref:`String` locale **)** Returns the :ref:`Translation` instance based on the ``locale`` passed in. It will return ``null`` if there is no :ref:`Translation` instance that matches the ``locale``. ---- .. _class_TranslationServer_method_pseudolocalize: - :ref:`StringName` **pseudolocalize** **(** :ref:`StringName` message **)** |const| Returns the pseudolocalized string based on the ``p_message`` passed in. ---- .. _class_TranslationServer_method_reload_pseudolocalization: - void **reload_pseudolocalization** **(** **)** Reparses the pseudolocalization options and reloads the translation. ---- .. _class_TranslationServer_method_remove_translation: - void **remove_translation** **(** :ref:`Translation` translation **)** Removes the given translation from the server. ---- .. _class_TranslationServer_method_set_locale: - void **set_locale** **(** :ref:`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. ---- .. _class_TranslationServer_method_standardize_locale: - :ref:`String` **standardize_locale** **(** :ref:`String` locale **)** |const| Returns ``locale`` string standardized to match known locales (e.g. ``en-US`` would be matched to ``en_US``). ---- .. _class_TranslationServer_method_translate: - :ref:`StringName` **translate** **(** :ref:`StringName` message, :ref:`StringName` context="" **)** |const| Returns the current locale's translation for the given message (key) and context. ---- .. _class_TranslationServer_method_translate_plural: - :ref:`StringName` **translate_plural** **(** :ref:`StringName` message, :ref:`StringName` plural_message, :ref:`int` n, :ref:`StringName` context="" **)** |const| 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.)`