Table of Contents

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

string

Messages

public Dictionary Messages { get; set; }

Property Value

Dictionary

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 StringName
xlatedMessage StringName
context 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 StringName
xlatedMessages string[]
context StringName

EraseMessage(StringName, StringName)

Erases a message.

public void EraseMessage(StringName srcMessage, StringName context = null)

Parameters

srcMessage StringName
context StringName

GetMessage(StringName, StringName)

Returns a message's translation.

public StringName GetMessage(StringName srcMessage, StringName context = null)

Parameters

srcMessage StringName
context StringName

Returns

StringName

GetMessageCount()

Returns the number of existing messages.

public int GetMessageCount()

Returns

int

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 StringName
srcPluralMessage StringName
n int
context StringName

Returns

StringName

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_name

Name of the method to check for.

Returns

bool

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_name

Name of the signal to check for.

Returns

bool

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_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

_GetMessage(StringName, StringName)

Virtual method to override GetMessage(StringName, StringName).

public virtual StringName _GetMessage(StringName srcMessage, StringName context)

Parameters

srcMessage StringName
context StringName

Returns

StringName

_GetPluralMessage(StringName, StringName, int, StringName)

public virtual StringName _GetPluralMessage(StringName srcMessage, StringName srcPluralMessage, int n, StringName context)

Parameters

srcMessage StringName
srcPluralMessage StringName
n int
context StringName

Returns

StringName