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 ( ) |
compare_locales ( String locale_a, String locale_b ) const |
|
get_all_countries ( ) const |
|
get_all_languages ( ) const |
|
get_all_scripts ( ) const |
|
get_country_name ( String country ) const |
|
get_language_name ( String language ) const |
|
get_loaded_locales ( ) const |
|
get_locale ( ) const |
|
get_locale_name ( String locale ) const |
|
get_script_name ( String script ) const |
|
void |
remove_translation ( Translation translation ) |
void |
set_locale ( String locale ) |
standardize_locale ( String locale ) 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).