Table of Contents

Class TranslationServer

Namespace
Godot
Assembly
GodotSharp.dll

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

public static class TranslationServer
Inheritance
TranslationServer
Inherited Members

Properties

PseudolocalizationEnabled

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

public static bool PseudolocalizationEnabled { get; set; }

Property Value

bool

Singleton

public static TranslationServerInstance Singleton { get; }

Property Value

TranslationServerInstance

Methods

AddTranslation(Translation)

Adds a Translation resource.

public static void AddTranslation(Translation translation)

Parameters

translation Translation

Clear()

Clears the server from all translations.

public static void Clear()

CompareLocales(string, string)

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

public static int CompareLocales(string localeA, string localeB)

Parameters

localeA string
localeB string

Returns

int

GetAllCountries()

Returns an array of known country codes.

public static string[] GetAllCountries()

Returns

string[]

GetAllLanguages()

Returns array of known language codes.

public static string[] GetAllLanguages()

Returns

string[]

GetAllScripts()

Returns an array of known script codes.

public static string[] GetAllScripts()

Returns

string[]

GetCountryName(string)

Returns a readable country name for the country code.

public static string GetCountryName(string country)

Parameters

country string

Returns

string

GetLanguageName(string)

Returns a readable language name for the language code.

public static string GetLanguageName(string language)

Parameters

language string

Returns

string

GetLoadedLocales()

Returns an array of all loaded locales of the project.

public static 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 static string GetLocale()

Returns

string

GetLocaleName(string)

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

public static string GetLocaleName(string locale)

Parameters

locale string

Returns

string

GetScriptName(string)

Returns a readable script name for the script code.

public static 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 static 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 static Translation GetTranslationObject(string locale)

Parameters

locale string

Returns

Translation

Pseudolocalize(StringName)

Returns the pseudolocalized string based on the message passed in.

public static StringName Pseudolocalize(StringName message)

Parameters

message StringName

Returns

StringName

ReloadPseudolocalization()

Reparses the pseudolocalization options and reloads the translation.

public static void ReloadPseudolocalization()

RemoveTranslation(Translation)

Removes the given translation from the server.

public static 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 static 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 static 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 static 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 static StringName TranslatePlural(StringName message, StringName pluralMessage, int n, StringName context = null)

Parameters

message StringName
pluralMessage StringName
n int
context StringName

Returns

StringName