Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Translation

Eredita: Resource < RefCounted < Object

Ereditato da: OptimizedTranslation

Una traduzione linguistica che mappa una raccolta di stringhe alle loro singole traduzioni.

Descrizione

Translation maps a collection of strings to their individual translations, and also provides convenience methods for pluralization.

A Translation consists of messages. A message is identified by its context and untranslated string. Unlike gettext, using an empty context string in Godot means not using any context.

Tutorial

Proprietà

String

locale

"en"

String

plural_rules_override

""

Metodi

StringName

_get_message(src_message: StringName, context: StringName) virtual const

StringName

_get_plural_message(src_message: StringName, src_plural_message: StringName, n: int, context: StringName) virtual const

void

add_message(src_message: StringName, xlated_message: StringName, context: StringName = &"")

void

add_plural_message(src_message: StringName, xlated_messages: PackedStringArray, context: StringName = &"")

void

erase_message(src_message: StringName, context: StringName = &"")

StringName

get_message(src_message: StringName, context: StringName = &"") const

int

get_message_count() const

PackedStringArray

get_message_list() const

StringName

get_plural_message(src_message: StringName, src_plural_message: StringName, n: int, context: StringName = &"") const

PackedStringArray

get_translated_message_list() const


Descrizioni delle proprietà

String locale = "en" 🔗

La lingua della traduzione.


String plural_rules_override = "" 🔗

  • void set_plural_rules_override(value: String)

  • String get_plural_rules_override()

The plural rules string to enforce. See GNU gettext for examples and more info.

If empty or invalid, default plural rules from TranslationServer.get_plural_rules() are used. The English plural rules are used as a fallback.


Descrizioni dei metodi

StringName _get_message(src_message: StringName, context: StringName) virtual const 🔗

Metodo virtuale per sovrascrivere get_message().


StringName _get_plural_message(src_message: StringName, src_plural_message: StringName, n: int, context: StringName) virtual const 🔗

Metodo virtuale per sovrascrivere get_plural_message().


void add_message(src_message: StringName, xlated_message: StringName, context: StringName = &"") 🔗

Aggiunge un messaggio se non esiste, seguito dalla sua traduzione.

Un contesto aggiuntivo potrebbe essere usato per specificare il contesto della traduzione o differenziare le parole polisemiche.


void add_plural_message(src_message: StringName, xlated_messages: PackedStringArray, context: StringName = &"") 🔗

Adds a message involving plural translation if nonexistent, followed by its translation.

An additional context could be used to specify the translation context or differentiate polysemic words.


void erase_message(src_message: StringName, context: StringName = &"") 🔗

Elimina un messaggio.


StringName get_message(src_message: StringName, context: StringName = &"") const 🔗

Restituisce la traduzione di un messaggio.


int get_message_count() const 🔗

Restituisce il numero di messaggi esistenti.


PackedStringArray get_message_list() const 🔗

Returns the keys of all messages, that is, the context and untranslated strings of each message.

Note: If a message does not use a context, the corresponding element is the untranslated string. Otherwise, the corresponding element is the context and untranslated string separated by the EOT character (U+0004). This is done for compatibility purposes.

for key in translation.get_message_list():
    var p = key.find("\u0004")
    if p == -1:
        var untranslated = key
        print("Message %s" % untranslated)
    else:
        var context = key.substr(0, p)
        var untranslated = key.substr(p + 1)
        print("Message %s with context %s" % [untranslated, context])

StringName get_plural_message(src_message: StringName, src_plural_message: StringName, n: int, context: StringName = &"") const 🔗

Restituisce la traduzione di un messaggio che include i plurali.

Il numero n è il numero o la quantità dell'oggetto plurale. Sarà utilizzato per guidare il sistema di traduzione a recuperare la forma plurale corretta per la lingua selezionata.

Nota: I plurali sono supportati solo nelle traduzioni basate su gettext (PO), non in CSV.


PackedStringArray get_translated_message_list() const 🔗

Returns all the translated strings.