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
Methods
AddTranslation(Translation)
Adds a Translation resource.
public void AddTranslation(Translation translation)
Parameters
translationTranslation
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
Returns
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
countrystring
Returns
GetLanguageName(string)
Returns a readable language name for the language code.
public string GetLanguageName(string language)
Parameters
languagestring
Returns
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
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
localestring
Returns
GetScriptName(string)
Returns a readable script name for the script code.
public string GetScriptName(string script)
Parameters
scriptstring
Returns
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
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
localestring
Returns
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
methodgodot_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
signalgodot_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
methodgodot_string_nameName of the method to invoke.
argsNativeVariantPtrArgsArguments to use with the invoked method.
retgodot_variantValue returned by the invoked method.
Returns
Pseudolocalize(StringName)
Returns the pseudolocalized string based on the message passed in.
public StringName Pseudolocalize(StringName message)
Parameters
messageStringName
Returns
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
translationTranslation
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
localestring
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
localestring
Returns
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
messageStringNamecontextStringName
Returns
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
messageStringNamepluralMessageStringNamenintcontextStringName