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

@ -27,13 +27,14 @@
<method name="get_loaded_locales" qualifiers="const">
<return type="Array" />
<description>
Returns an Array of all loaded locales of the game.
Returns an array of all loaded locales of the project.
</description>
</method>
<method name="get_locale" qualifiers="const">
<return type="String" />
<description>
Returns the current locale of the game.
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.
</description>
</method>
<method name="get_locale_name" qualifiers="const">
@ -75,7 +76,8 @@
<return type="void" />
<argument index="0" name="locale" type="String" />
<description>
Sets the locale of the game.
Sets the locale of the project. The [code]locale[/code] 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.
</description>
</method>
<method name="translate" qualifiers="const">