TranslationServer

package
v0.0.0-...-b67d1b4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 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 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 Clear

func Clear()

Removes all translations from the main translation domain.

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 GetOrAddDomain

func GetOrAddDomain(domain string) [1]gdclass.TranslationDomain

Returns the translation domain with the specified name. An empty translation domain will be created and added if it does not exist.

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 that best matches [param locale] in the main translation domain. Returns [code]null[/code] if there are no matches.

func HasDomain

func HasDomain(domain string) bool

Returns [code]true[/code] if a translation domain with the specified name exists.

func PseudolocalizationEnabled

func PseudolocalizationEnabled() bool

func Pseudolocalize

func Pseudolocalize(message string) string

Returns the pseudolocalized string based on the [param message] passed in. [b]Note:[/b] 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. [b]Note:[/b] Trying to remove the main translation domain is an error.

func RemoveTranslation

func RemoveTranslation(translation [1]gdclass.Translation)

Removes the given translation from the main translation domain.

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]). If [param add_defaults] is [code]true[/code], the locale may have a default script or country added.

func Translate

func Translate(message string) string

Returns the current locale's translation for the given message and context. [b]Note:[/b] This method always uses the main translation domain.

func TranslatePlural

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

Returns the current locale's translation for the given message, 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. [b]Note:[/b] This method always uses the main translation domain.

Types

This section is empty.

Jump to

Keyboard shortcuts

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