1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Implement OS::get_locale_language() helper method

This method extracts the 2 or 3-letter language code from `OS::get_locale()`,
making it easier for users to identify the "main" language code for users
that might have different OS locales due to different OS or region, but
should be matched to the same translation (e.g. "generic" Spanish).

Fixes #40703.
This commit is contained in:
Rémi Verschelde
2021-09-16 09:27:56 +02:00
parent 73ec378c64
commit def99c7baf
6 changed files with 26 additions and 4 deletions

View File

@@ -286,6 +286,10 @@ String OS::get_locale() const {
return ::OS::get_singleton()->get_locale();
}
String OS::get_locale_language() const {
return ::OS::get_singleton()->get_locale_language();
}
String OS::get_model_name() const {
return ::OS::get_singleton()->get_model_name();
}
@@ -547,6 +551,7 @@ void OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("delay_usec", "usec"), &OS::delay_usec);
ClassDB::bind_method(D_METHOD("delay_msec", "msec"), &OS::delay_msec);
ClassDB::bind_method(D_METHOD("get_locale"), &OS::get_locale);
ClassDB::bind_method(D_METHOD("get_locale_language"), &OS::get_locale_language);
ClassDB::bind_method(D_METHOD("get_model_name"), &OS::get_model_name);
ClassDB::bind_method(D_METHOD("is_userfs_persistent"), &OS::is_userfs_persistent);