:github_url: hide .. _class_TranslationServer: TranslationServer ================= **Eredita:** :ref:`Object` Il server responsabile delle traduzioni linguistiche. .. rst-class:: classref-introduction-group Descrizione ---------------------- Il server di traduzione è il backend API che gestisce tutte le traduzioni linguistiche. Le traduzioni sono archiviate nei :ref:`TranslationDomain`, a cui si può accedere per nome. Il dominio di traduzione più comunemente utilizzato è il dominio di traduzione principale. Esiste sempre e vi si può accedere tramite uno :ref:`StringName` vuoto. Il server di traduzione fornisce metodi wrapper per accedere direttamente al dominio di traduzione principale, senza dover prima recuperare il dominio di traduzione. I domini di traduzione personalizzati sono principalmente per usi avanzati come le estensioni dell'editor. I nomi che iniziano con ``godot.`` sono riservati per le parti interne del motore. .. rst-class:: classref-introduction-group Tutorial ---------------- - :doc:`Internazionalizzazione dei giochi <../tutorials/i18n/internationalizing_games>` - :doc:`Localizzazione <../tutorials/i18n/locales>` .. rst-class:: classref-reftable-group Proprietà ------------------ .. table:: :widths: auto +-------------------------+------------------------------------------------------------------------------------------------+-----------+ | :ref:`bool` | :ref:`pseudolocalization_enabled` | ``false`` | +-------------------------+------------------------------------------------------------------------------------------------+-----------+ .. rst-class:: classref-reftable-group Metodi ------------ .. table:: :widths: auto +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`add_translation`\ (\ translation\: :ref:`Translation`\ ) | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`clear`\ (\ ) | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`compare_locales`\ (\ locale_a\: :ref:`String`, locale_b\: :ref:`String`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array`\[:ref:`Translation`\] | :ref:`find_translations`\ (\ locale\: :ref:`String`, exact\: :ref:`bool`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`format_number`\ (\ number\: :ref:`String`, locale\: :ref:`String`\ ) |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`\ (\ country\: :ref:`String`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_language_name`\ (\ language\: :ref:`String`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`PackedStringArray` | :ref:`get_loaded_locales`\ (\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_locale`\ (\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_locale_name`\ (\ locale\: :ref:`String`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`TranslationDomain` | :ref:`get_or_add_domain`\ (\ domain\: :ref:`StringName`\ ) | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_percent_sign`\ (\ locale\: :ref:`String`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_plural_rules`\ (\ locale\: :ref:`String`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_script_name`\ (\ script\: :ref:`String`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_tool_locale`\ (\ ) | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Translation` | :ref:`get_translation_object`\ (\ locale\: :ref:`String`\ ) | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array`\[:ref:`Translation`\] | :ref:`get_translations`\ (\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_domain`\ (\ domain\: :ref:`StringName`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_translation`\ (\ translation\: :ref:`Translation`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_translation_for_locale`\ (\ locale\: :ref:`String`, exact\: :ref:`bool`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`parse_number`\ (\ number\: :ref:`String`, locale\: :ref:`String`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`pseudolocalize`\ (\ message\: :ref:`StringName`\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`reload_pseudolocalization`\ (\ ) | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`remove_domain`\ (\ domain\: :ref:`StringName`\ ) | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`remove_translation`\ (\ translation\: :ref:`Translation`\ ) | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_locale`\ (\ locale\: :ref:`String`\ ) | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`standardize_locale`\ (\ locale\: :ref:`String`, add_defaults\: :ref:`bool` = false\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`translate`\ (\ message\: :ref:`StringName`, context\: :ref:`StringName` = &""\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`StringName` | :ref:`translate_plural`\ (\ message\: :ref:`StringName`, plural_message\: :ref:`StringName`, n\: :ref:`int`, context\: :ref:`StringName` = &""\ ) |const| | +--------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Descrizioni delle proprietà ------------------------------------------------------ .. _class_TranslationServer_property_pseudolocalization_enabled: .. rst-class:: classref-property :ref:`bool` **pseudolocalization_enabled** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_pseudolocalization_enabled**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **is_pseudolocalization_enabled**\ (\ ) Se ``true``, abilita l'uso della pseudolocalizzazione sul dominio di traduzione principale. Vedi :ref:`ProjectSettings.internationalization/pseudolocalization/use_pseudolocalization` per i dettagli. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Descrizioni dei metodi -------------------------------------------- .. _class_TranslationServer_method_add_translation: .. rst-class:: classref-method |void| **add_translation**\ (\ translation\: :ref:`Translation`\ ) :ref:`🔗` Aggiunge una traduzione al dominio di traduzione principale. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_clear: .. rst-class:: classref-method |void| **clear**\ (\ ) :ref:`🔗` Rimuove tutte le traduzioni dal dominio di traduzione principale. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_compare_locales: .. rst-class:: classref-method :ref:`int` **compare_locales**\ (\ locale_a\: :ref:`String`, locale_b\: :ref:`String`\ ) |const| :ref:`🔗` Confronta due impostazioni locali e restituisce un punteggio di similarità tra ``0`` (nessuna corrispondenza) e ``10`` (corrispondenza totale). .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_find_translations: .. rst-class:: classref-method :ref:`Array`\[:ref:`Translation`\] **find_translations**\ (\ locale\: :ref:`String`, exact\: :ref:`bool`\ ) |const| :ref:`🔗` Returns the :ref:`Translation` instances in the main translation domain that match ``locale`` (see :ref:`compare_locales()`). If ``exact`` is ``true``, only instances whose locale exactly equals ``locale`` will be returned. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_format_number: .. rst-class:: classref-method :ref:`String` **format_number**\ (\ number\: :ref:`String`, locale\: :ref:`String`\ ) |const| :ref:`🔗` Converts a number from Western Arabic (0..9) to the numeral system used in the given ``locale``. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_all_countries: .. rst-class:: classref-method :ref:`PackedStringArray` **get_all_countries**\ (\ ) |const| :ref:`🔗` Restituisce un array di codici paese noti. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_all_languages: .. rst-class:: classref-method :ref:`PackedStringArray` **get_all_languages**\ (\ ) |const| :ref:`🔗` Restituisce un array di codici di lingua noti. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_all_scripts: .. rst-class:: classref-method :ref:`PackedStringArray` **get_all_scripts**\ (\ ) |const| :ref:`🔗` Restituisce un array di codici alfabeto noti. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_country_name: .. rst-class:: classref-method :ref:`String` **get_country_name**\ (\ country\: :ref:`String`\ ) |const| :ref:`🔗` Restituisce un nome di paese leggibile per il codice paese ``country``. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_language_name: .. rst-class:: classref-method :ref:`String` **get_language_name**\ (\ language\: :ref:`String`\ ) |const| :ref:`🔗` Restituisce un nome di lingua leggibile per il codice di lingua ``language``. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_loaded_locales: .. rst-class:: classref-method :ref:`PackedStringArray` **get_loaded_locales**\ (\ ) |const| :ref:`🔗` Restituisce un array di tutte le impostazioni locali caricate del progetto. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_locale: .. rst-class:: classref-method :ref:`String` **get_locale**\ (\ ) |const| :ref:`🔗` Restituisce la localizzazione attuale del progetto. Vedi anche :ref:`OS.get_locale()` e :ref:`OS.get_locale_language()` per recuperare la localizzazione del sistema utente. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_locale_name: .. rst-class:: classref-method :ref:`String` **get_locale_name**\ (\ locale\: :ref:`String`\ ) |const| :ref:`🔗` Restituisce la lingua di una localizzazione e la sua variante (ad esempio ``"it_IT"`` restituirebbe ``"Italiano (Italia)"``). .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_or_add_domain: .. rst-class:: classref-method :ref:`TranslationDomain` **get_or_add_domain**\ (\ domain\: :ref:`StringName`\ ) :ref:`🔗` Restituisce il dominio di traduzione con il nome specificato. Un dominio di traduzione vuoto verrà creato e aggiunto se non esiste. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_percent_sign: .. rst-class:: classref-method :ref:`String` **get_percent_sign**\ (\ locale\: :ref:`String`\ ) |const| :ref:`🔗` Returns the percent sign used in the given ``locale``. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_plural_rules: .. rst-class:: classref-method :ref:`String` **get_plural_rules**\ (\ locale\: :ref:`String`\ ) |const| :ref:`🔗` Returns the default plural rules for the ``locale``. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_script_name: .. rst-class:: classref-method :ref:`String` **get_script_name**\ (\ script\: :ref:`String`\ ) |const| :ref:`🔗` Restituisce un nome leggibile di alfabeto per il codice alfabeto ``script``. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_tool_locale: .. rst-class:: classref-method :ref:`String` **get_tool_locale**\ (\ ) :ref:`🔗` Restituisce la localizzazione attuale dell'editor. \ **Nota:** Quando viene chiamato da un progetto esportato, restituisce lo stesso valore di :ref:`get_locale()`. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_translation_object: .. rst-class:: classref-method :ref:`Translation` **get_translation_object**\ (\ locale\: :ref:`String`\ ) :ref:`🔗` **Deprecato:** Use :ref:`find_translations()` instead. Restituisce l'istanza di :ref:`Translation` che corrisponde di più alla localizzazione ``locale`` nel dominio di traduzione principale. Restituisce ``null`` se non ci sono corrispondenze. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_get_translations: .. rst-class:: classref-method :ref:`Array`\[:ref:`Translation`\] **get_translations**\ (\ ) |const| :ref:`🔗` Returns all available :ref:`Translation` instances in the main translation domain as added by :ref:`add_translation()`. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_has_domain: .. rst-class:: classref-method :ref:`bool` **has_domain**\ (\ domain\: :ref:`StringName`\ ) |const| :ref:`🔗` Restituisce ``true`` se esiste un dominio di traduzione con il nome specificato. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_has_translation: .. rst-class:: classref-method :ref:`bool` **has_translation**\ (\ translation\: :ref:`Translation`\ ) |const| :ref:`🔗` Returns ``true`` if the main translation domain contains the given ``translation``. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_has_translation_for_locale: .. rst-class:: classref-method :ref:`bool` **has_translation_for_locale**\ (\ locale\: :ref:`String`, exact\: :ref:`bool`\ ) |const| :ref:`🔗` Returns ``true`` if there are any :ref:`Translation` instances in the main translation domain that match ``locale`` (see :ref:`compare_locales()`). If ``exact`` is ``true``, only instances whose locale exactly equals ``locale`` are considered. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_parse_number: .. rst-class:: classref-method :ref:`String` **parse_number**\ (\ number\: :ref:`String`, locale\: :ref:`String`\ ) |const| :ref:`🔗` Converts ``number`` from the numeral system used in the given ``locale`` to Western Arabic (0..9). .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_pseudolocalize: .. rst-class:: classref-method :ref:`StringName` **pseudolocalize**\ (\ message\: :ref:`StringName`\ ) |const| :ref:`🔗` Restituisce la stringa pseudolocalizzata in base al messaggio ``message`` passato. \ **Nota:** Questo metodo utilizza sempre il dominio di traduzione principale. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_reload_pseudolocalization: .. rst-class:: classref-method |void| **reload_pseudolocalization**\ (\ ) :ref:`🔗` Riesamina le opzioni di pseudolocalizzazione e ricarica la traduzione dal dominio di traduzione principale. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_remove_domain: .. rst-class:: classref-method |void| **remove_domain**\ (\ domain\: :ref:`StringName`\ ) :ref:`🔗` Rimuove il dominio di traduzione con il nome specificato. \ **Nota:** Tentare di rimuovere il dominio di traduzione principale è un errore. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_remove_translation: .. rst-class:: classref-method |void| **remove_translation**\ (\ translation\: :ref:`Translation`\ ) :ref:`🔗` Rimuove la traduzione specificata dal dominio di traduzione principale. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_set_locale: .. rst-class:: classref-method |void| **set_locale**\ (\ locale\: :ref:`String`\ ) :ref:`🔗` Imposta la localizzazione del progetto. La stringa ``locale`` sarà standardizzata per corrispondere alle localizzazioni note (ad esempio, ``en-US`` sarebbe abbinata a ``en_US``). Se sono state caricate traduzioni in precedenza per la nuova localizzazione, saranno applicate. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_standardize_locale: .. rst-class:: classref-method :ref:`String` **standardize_locale**\ (\ locale\: :ref:`String`, add_defaults\: :ref:`bool` = false\ ) |const| :ref:`🔗` Restituisce una stringa ``locale`` standardizzata per corrispondere alle localizzazioni note (ad esempio, ``en-US`` sarebbe abbinato a ``en_US``). Se ``add_defaults`` è ``true``, è possibile che alla localizzazione sia aggiunto un alfabeto o un paese predefinito. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_translate: .. rst-class:: classref-method :ref:`StringName` **translate**\ (\ message\: :ref:`StringName`, context\: :ref:`StringName` = &""\ ) |const| :ref:`🔗` Restituisce la traduzione della lingua attuale per il messaggio e il contesto specificati. \ **Nota:** Questo metodo utilizza sempre il dominio di traduzione principale. .. rst-class:: classref-item-separator ---- .. _class_TranslationServer_method_translate_plural: .. rst-class:: classref-method :ref:`StringName` **translate_plural**\ (\ message\: :ref:`StringName`, plural_message\: :ref:`StringName`, n\: :ref:`int`, context\: :ref:`StringName` = &""\ ) |const| :ref:`🔗` Restituisce la traduzione della localizzazione attuale per il messaggio, il messaggio plurale e il contesto specificati. Il numero ``n`` è il numero o la quantità dell'oggetto plurale. Sarà usato per guidare il sistema di traduzione a recuperare la forma plurale corretta per la lingua selezionata. \ **Nota:** Questo metodo utilizza sempre il dominio di traduzione principale. .. |virtual| replace:: :abbr:`virtual (Questo metodo dovrebbe solitamente essere sovrascritto dall'utente per aver un effetto.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (Questo metodo non ha effetti collaterali. Non modifica alcuna variabile appartenente all'istanza.)` .. |vararg| replace:: :abbr:`vararg (Questo metodo accetta qualsiasi numero di argomenti oltre a quelli descritti qui.)` .. |constructor| replace:: :abbr:`constructor (Questo metodo è utilizzato per creare un tipo.)` .. |static| replace:: :abbr:`static (Questo metodo non necessita di alcun'istanza per essere chiamato, quindi può essere chiamato direttamente usando il nome della classe.)` .. |operator| replace:: :abbr:`operator (Questo metodo descrive un operatore valido da usare con questo tipo come operando di sinistra.)` .. |bitfield| replace:: :abbr:`BitField (Questo valore è un intero composto da una maschera di bit dei seguenti flag.)` .. |void| replace:: :abbr:`void (Nessun valore restituito.)`