Class Translation
- Namespace
- Godot
- Assembly
- GodotSharp.dll
Translations are resources that can be loaded and unloaded on demand. They map a collection of strings to their individual translations, and they also provide convenience methods for pluralization.
public class Translation : Resource, IDisposable
- Inheritance
-
Translation
- Implements
- Derived
- Inherited Members
Constructors
Translation()
public Translation()
Properties
Locale
The locale of the translation.
public string Locale { get; set; }
Property Value
Messages
public Dictionary Messages { get; set; }
Property Value
Methods
AddMessage(StringName, StringName, StringName)
Adds a message if nonexistent, followed by its translation.
An additional context could be used to specify the translation context or differentiate polysemic words.
public void AddMessage(StringName srcMessage, StringName xlatedMessage, StringName context = null)
Parameters
srcMessage
StringNamexlatedMessage
StringNamecontext
StringName
AddPluralMessage(StringName, string[], 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.
public void AddPluralMessage(StringName srcMessage, string[] xlatedMessages, StringName context = null)
Parameters
srcMessage
StringNamexlatedMessages
string[]context
StringName
EraseMessage(StringName, StringName)
Erases a message.
public void EraseMessage(StringName srcMessage, StringName context = null)
Parameters
srcMessage
StringNamecontext
StringName
GetMessage(StringName, StringName)
Returns a message's translation.
public StringName GetMessage(StringName srcMessage, StringName context = null)
Parameters
srcMessage
StringNamecontext
StringName
Returns
GetMessageCount()
Returns the number of existing messages.
public int GetMessageCount()
Returns
GetMessageList()
Returns all the messages (keys).
public string[] GetMessageList()
Returns
- string[]
GetPluralMessage(StringName, StringName, int, StringName)
Returns a message's translation involving plurals.
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.
public StringName GetPluralMessage(StringName srcMessage, StringName srcPluralMessage, int n, StringName context = null)
Parameters
srcMessage
StringNamesrcPluralMessage
StringNamen
intcontext
StringName
Returns
GetTranslatedMessageList()
Returns all the messages (translated text).
public string[] GetTranslatedMessageList()
Returns
- string[]
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
_GetMessage(StringName, StringName)
Virtual method to override GetMessage(StringName, StringName).
public virtual StringName _GetMessage(StringName srcMessage, StringName context)
Parameters
srcMessage
StringNamecontext
StringName
Returns
_GetPluralMessage(StringName, StringName, int, StringName)
Virtual method to override GetPluralMessage(StringName, StringName, int, StringName).
public virtual StringName _GetPluralMessage(StringName srcMessage, StringName srcPluralMessage, int n, StringName context)
Parameters
srcMessage
StringNamesrcPluralMessage
StringNamen
intcontext
StringName