TranslationServer

Inherits: Object

Server that manages all translations.

Description

Server that manages all translations. Translations can be set to it and removed from it.

Tutorials

Methods

void

add_translation ( Translation translation )

void

clear ( )

int

compare_locales ( String locale_a, String locale_b ) const

PoolStringArray

get_all_countries ( ) const

PoolStringArray

get_all_languages ( ) const

PoolStringArray

get_all_scripts ( ) const

String

get_country_name ( String country ) const

String

get_language_name ( String language ) const

Array

get_loaded_locales ( ) const

String

get_locale ( ) const

String

get_locale_name ( String locale ) const

String

get_script_name ( String script ) const

void

remove_translation ( Translation translation )

void

set_locale ( String locale )

String

standardize_locale ( String locale ) const

String

translate ( String message ) const


Method Descriptions

void add_translation ( Translation translation )

Adds a Translation resource.


void clear ( )

Clears the server from all translations.


int compare_locales ( String locale_a, String locale_b ) const

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


PoolStringArray get_all_countries ( ) const

Returns array of known country codes.


PoolStringArray get_all_languages ( ) const

Returns array of known language codes.


PoolStringArray get_all_scripts ( ) const

Returns array of known script codes.


String get_country_name ( String country ) const

Returns readable country name for the country code.


String get_language_name ( String language ) const

Returns readable language name for the language code.


Array get_loaded_locales ( ) const

Returns an array of all loaded locales of the project.


String get_locale ( ) const

Returns the current locale of the project.

See also OS.get_locale and OS.get_locale_language to query the locale of the user system.


String get_locale_name ( String locale ) const

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


String get_script_name ( String script ) const

Returns readable script name for the script code.


void remove_translation ( Translation translation )

Removes the given translation from the server.


void set_locale ( String locale )

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.


String standardize_locale ( String locale ) const

Returns locale string standardized to match known locales (e.g. en-US would be matched to en_US).


String translate ( String message ) const

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