[Solved] Bengali language code

Royagers

  • *
  • Posts: 40
Why Stencyl detects Bengali as "xu"?

« Last Edit: October 14, 2023, 11:14:01 am by makaydenko »

Justin

  • *
  • Posts: 4716
Can you be a bit more specific? Is this in the toolset somewhere? In the runtime engine somewhere?
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Royagers

  • *
  • Posts: 40
I changed the language on my Android device to Bengali. Then I printed to console a value of the "language" block of the Flow blocks group (Constants section) and Stencyl log viewer shows me "xu".

Justin

  • *
  • Posts: 4716
Ok. That block uses the following code:
Code: [Select]
openfl.system.Capabilities.language

Here's a link to the documentation for that property: openfl.system.Capabilities.language

And here's a copy of the documentation:

Code: [Select]
/**
Specifies the language code of the system on which the content is
running. The language is specified as a lowercase two-letter language
code from ISO 639-1. For Chinese, an additional uppercase two-letter
country code from ISO 3166 distinguishes between Simplified and
Traditional Chinese. The languages codes are based on the English
names of the language: for example, `hu` specifies Hungarian.
On English systems, this property returns only the language code
(`en`), not the country code. On Microsoft Windows systems, this
property returns the user interface (UI) language, which refers to the
language used for all menus, dialog boxes, error messages, and help
files. The following table lists the possible values:

| Language | Value |
| --- | --- |
| Czech | `cs` |
| Danish | `da` |
| Dutch | `nl` |
| English | `en` |
| Finnish | `fi` |
| French | `fr` |
| German | `de` |
| Hungarian | `hu` |
| Italian | `it` |
| Japanese | `ja` |
| Korean | `ko` |
| Norwegian | `no` |
| Other/unknown | `xu` |
| Polish | `pl` |
| Portuguese | `pt` |
| Russian | `ru` |
| Simplified Chinese | `zh-CN` |
| Spanish | `es` |
| Swedish | `sv` |
| Traditional Chinese | `zh-TW` |
| Turkish | `tr` |

_Note:_ The value of `Capabilities.language` property is limited to
the possible values on this list. Because of this limitation, Adobe
AIR applications should use the first element in the
`Capabilities.languages` array to determine the primary user interface
language for the system.

The server string is `L`.
**/
public static var language(get, never):String;

Unfortunately, I guess the return value of "xu" is this working as intended.

If we take a look at how language is determined, we can see that it's doing this under the hood:

Code: [Select]
@:noCompletion private static function get_language():String
{
#if lime
var language = Locale.currentLocale.language;

if (language != null)
{
language = language.toLowerCase();

switch (language)
{
case "cs", "da", "nl", "en", "fi", "fr", "de", "hu", "it", "ja", "ko", "nb", "pl", "pt", "ru", "es", "sv", "tr":
return language;

case "zh":
var region = Locale.currentLocale.region;

if (region != null)
{
switch (region.toUpperCase())
{
case "TW", "HANT":
return "zh-TW";

default:
}
}

return "zh-CN";

default:
return "xu";
}
}
#end

return "en";
}

Looks like the answer lies with lime.system.Locale.currentLocale.language and lime.system.Locale.currentLocale.region.

Perhaps you can try putting those into a code block and see if they give you what you want.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)


Royagers

  • *
  • Posts: 40
Can I use an external Haxe library (for example: https://lib.haxe.org/p/devicelanguage) to detect system language in Stencyl?

Royagers

  • *
  • Posts: 40
I decided to use a language selection scene for the user.