Table of Contents

Class TranslationServerInstance

Namespace
Godot
Assembly
GodotSharp.dll

The server that manages all language translations. Translations can be added to or removed from it.

[GodotClassName("TranslationServer")]
public class TranslationServerInstance : GodotObject, IDisposable
Inheritance
TranslationServerInstance
Implements
Inherited Members

Properties

PseudolocalizationEnabled

If true, enables the use of pseudolocalization. See ProjectSettings.internationalization/pseudolocalization/use_pseudolocalization for details.

public bool PseudolocalizationEnabled { get; set; }

Property Value

bool

Methods

AddTranslation(Translation)

Adds a Translation resource.

public void AddTranslation(Translation translation)

Parameters

translation Translation

Clear()

Clears the server from all translations.

public void Clear()

CompareLocales(string, string)

Compares two locales and returns a similarity score between 0 (no match) and 10 (full match).

public int CompareLocales(string localeA, string localeB)

Parameters

localeA string
localeB string

Returns

int

GetAllCountries()

Returns an array of known country codes.

public string[] GetAllCountries()

Returns

string[]

GetAllLanguages()

Returns array of known language codes.

public string[] GetAllLanguages()

Returns

string[]

GetAllScripts()

Returns an array of known script codes.

public string[] GetAllScripts()

Returns

string[]

GetCountryName(string)

Returns a readable country name for the country code.

public string GetCountryName(string country)

Parameters

country string

Returns

string

GetLanguageName(string)

Returns a readable language name for the language code.

public string GetLanguageName(string language)

Parameters

language string

Returns

string

GetLoadedLocales()

Returns an array of all loaded locales of the project.

public string[] GetLoadedLocales()

Returns

string[]

GetLocale()

Returns the current locale of the project.

See also GetLocale() and GetLocaleLanguage() to query the locale of the user system.

public string GetLocale()

Returns

string

GetLocaleName(string)

Returns a locale's language and its variant (e.g. "en_US" would return "English (United States)").

public string GetLocaleName(string locale)

Parameters

locale string

Returns

string

GetScriptName(string)

Returns a readable script name for the script code.

public string GetScriptName(string script)

Parameters

script string

Returns

string

GetToolLocale()

Returns the current locale of the editor.

Note: When called from an exported project returns the same value as GetLocale().

public string GetToolLocale()

Returns

string

GetTranslationObject(string)

Returns the Translation instance based on the locale passed in.

It will return null if there is no Translation instance that matches the locale.

public Translation GetTranslationObject(string locale)

Parameters

locale string

Returns

Translation

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

Pseudolocalize(StringName)

Returns the pseudolocalized string based on the message passed in.

public StringName Pseudolocalize(StringName message)

Parameters

message StringName

Returns

StringName

ReloadPseudolocalization()

Reparses the pseudolocalization options and reloads the translation.

public void ReloadPseudolocalization()

RemoveTranslation(Translation)

Removes the given translation from the server.

public void RemoveTranslation(Translation translation)

Parameters

translation Translation

SetLocale(string)

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.

public void SetLocale(string locale)

Parameters

locale string

StandardizeLocale(string)

Returns a locale string standardized to match known locales (e.g. en-US would be matched to en_US).

public string StandardizeLocale(string locale)

Parameters

locale string

Returns

string

Translate(StringName, StringName)

Returns the current locale's translation for the given message (key) and context.

public StringName Translate(StringName message, StringName context = null)

Parameters

message StringName
context StringName

Returns

StringName

TranslatePlural(StringName, StringName, int, StringName)

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.

public StringName TranslatePlural(StringName message, StringName pluralMessage, int n, StringName context = null)

Parameters

message StringName
pluralMessage StringName
n int
context StringName

Returns

StringName