TranslationServer

package
v0.0.0-...-01268d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package TranslationServer provides methods for working with TranslationServer object instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTranslation

func AddTranslation(translation [1]gdclass.Translation)

Adds a [Translation] resource.

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 Clear

func Clear()

Clears the server from all translations.

func CompareLocales

func CompareLocales(locale_a string, locale_b string) int

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

func GetAllCountries

func GetAllCountries() []string

Returns an array of known country codes.

func GetAllLanguages

func GetAllLanguages() []string

Returns array of known language codes.

func GetAllScripts

func GetAllScripts() []string

Returns an array of known script codes.

func GetCountryName

func GetCountryName(country string) string

Returns a readable country name for the [param country] code.

func GetLanguageName

func GetLanguageName(language string) string

Returns a readable language name for the [param 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 [method OS.get_locale] and [method OS.get_locale_language] to query the locale of the user system.

func GetLocaleName

func GetLocaleName(locale string) string

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

func GetScriptName

func GetScriptName(script string) string

Returns a readable script name for the [param script] code.

func GetToolLocale

func GetToolLocale() string

Returns the current locale of the editor. [b]Note:[/b] When called from an exported project returns the same value as [method get_locale].

func GetTranslationObject

func GetTranslationObject(locale string) [1]gdclass.Translation

Returns the [Translation] instance based on the [param locale] passed in. It will return [code]null[/code] if there is no [Translation] instance that matches the [param locale].

func PseudolocalizationEnabled

func PseudolocalizationEnabled() bool

func Pseudolocalize

func Pseudolocalize(message string) string

Returns the pseudolocalized string based on the [param message] passed in.

func ReloadPseudolocalization

func ReloadPseudolocalization()

Reparses the pseudolocalization options and reloads the translation.

func RemoveTranslation

func RemoveTranslation(translation [1]gdclass.Translation)

Removes the given translation from the server.

func SetLocale

func SetLocale(locale string)

Sets the locale of the project. The [param locale] string will be standardized to match known locales (e.g. [code]en-US[/code] would be matched to [code]en_US[/code]). If translations have been loaded beforehand for the new locale, they will be applied.

func SetPseudolocalizationEnabled

func SetPseudolocalizationEnabled(value bool)

func StandardizeLocale

func StandardizeLocale(locale string) string

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

func Translate

func Translate(message string) string

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

func TranslatePlural

func TranslatePlural(message string, plural_message string, n int) string

Returns the current locale's translation for the given message (key), plural message and context. The number [param 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL