Documentation
¶
Overview ¶
The translation server is the API backend that manages all language translations.
Translations are stored in [graphics.gd/classdb/TranslationDomain]s, which can be accessed by name. The most commonly used translation domain is the main translation domain. It always exists and can be accessed using an empty string. The translation server provides wrapper methods for accessing the main translation domain directly, without having to fetch the translation domain first. Custom translation domains are mainly for advanced usages like editor plugins. Names starting with godot. are reserved for engine internals.
Index ¶
- func AddTranslation(translation Translation.Instance)
- func Advanced() class
- func Clear()
- func CompareLocales(locale_a string, locale_b string) int
- func GetAllCountries() []string
- func GetAllLanguages() []string
- func GetAllScripts() []string
- func GetCountryName(country string) string
- func GetLanguageName(language string) string
- func GetLoadedLocales() []string
- func GetLocale() string
- func GetLocaleName(locale string) string
- func GetOrAddDomain(domain string) TranslationDomain.Instance
- func GetScriptName(script string) string
- func GetToolLocale() string
- func GetTranslationObject(locale string) Translation.Instance
- func HasDomain(domain string) bool
- func PseudolocalizationEnabled() bool
- func Pseudolocalize(message string) string
- func ReloadPseudolocalization()
- func RemoveDomain(domain string)
- func RemoveTranslation(translation Translation.Instance)
- func SetLocale(locale string)
- func SetPseudolocalizationEnabled(value bool)
- func StandardizeLocale(locale string, add_defaults bool) string
- func StandardizeLocaleOptions(locale string, add_defaults bool) string
- func Translate(message string, context string) string
- func TranslateOptions(message string, context string) string
- func TranslatePlural(message string, plural_message string, n int, context string) string
- func TranslatePluralOptions(message string, plural_message string, n int, context string) string
- type Extension
- type ID
- type Instance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTranslation ¶
func AddTranslation(translation Translation.Instance)
Adds a translation to the main translation domain.
func Advanced ¶
func Advanced() class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
func CompareLocales ¶
Compares two locales and returns a similarity score between 0 (no match) and 10 (full match).
func GetCountryName ¶
Returns a readable country name for the 'country' code.
func GetLanguageName ¶
Returns a readable language name for the 'language' code.
func GetLoadedLocales ¶
func GetLoadedLocales() []string
Returns an array of all loaded locales of the project.
func GetLocale ¶
func GetLocale() string
Returns the current locale of the project.
See also graphics.gd/classdb/OS.GetLocale and graphics.gd/classdb/OS.GetLocaleLanguage to query the locale of the user system.
func GetLocaleName ¶
Returns a locale's language and its variant (e.g. "en_US" would return "English (United States)").
func GetOrAddDomain ¶
func GetOrAddDomain(domain string) TranslationDomain.Instance
Returns the translation domain with the specified name. An empty translation domain will be created and added if it does not exist.
func GetScriptName ¶
Returns a readable script name for the 'script' code.
func GetToolLocale ¶
func GetToolLocale() string
Returns the current locale of the editor.
Note: When called from an exported project returns the same value as GetLocale.
func GetTranslationObject ¶
func GetTranslationObject(locale string) Translation.Instance
Returns the graphics.gd/classdb/Translation instance that best matches 'locale' in the main translation domain. Returns null if there are no matches.
func PseudolocalizationEnabled ¶
func PseudolocalizationEnabled() bool
func Pseudolocalize ¶
Returns the pseudolocalized string based on the 'message' passed in.
Note: This method always uses the main translation domain.
func ReloadPseudolocalization ¶
func ReloadPseudolocalization()
Reparses the pseudolocalization options and reloads the translation for the main translation domain.
func RemoveDomain ¶
func RemoveDomain(domain string)
Removes the translation domain with the specified name.
Note: Trying to remove the main translation domain is an error.
func RemoveTranslation ¶
func RemoveTranslation(translation Translation.Instance)
Removes the given translation from the main translation domain.
func SetLocale ¶
func SetLocale(locale 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.
func SetPseudolocalizationEnabled ¶
func SetPseudolocalizationEnabled(value bool)
func StandardizeLocale ¶
Returns a 'locale' string standardized to match known locales (e.g. en-US would be matched to en_US). If 'add_defaults' is true, the locale may have a default script or country added.
func StandardizeLocaleOptions ¶
Returns a 'locale' string standardized to match known locales (e.g. en-US would be matched to en_US). If 'add_defaults' is true, the locale may have a default script or country added.
func Translate ¶
Returns the current locale's translation for the given message and context.
Note: This method always uses the main translation domain.
func TranslateOptions ¶
Returns the current locale's translation for the given message and context.
Note: This method always uses the main translation domain.
func TranslatePlural ¶
Returns the current locale's translation for the given message, 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.
Note: This method always uses the main translation domain.
func TranslatePluralOptions ¶
Returns the current locale's translation for the given message, 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.
Note: This method always uses the main translation domain.
Types ¶
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.TranslationServer
Instance of the class with convieniently typed arguments and results.