Localization
The Y8 SDK allows your game to detect the current platform locale.
The locale is determined from the platform domain and can be used to automatically select the appropriate language for your game.
Authentication
Localization does not require the player to be authenticated.
Get Platform Locale
Retrieve the current platform locale.
y8Sdk.getPlatformLocale()
.then((locale) => {
console.log("Platform locale:", locale);
})
.catch((error) => {
console.error(error.message);
});
The Promise resolves with a locale code.
JsResponse<PlatformLocale> response =
await Y8.Instance.GetPlatformLocaleAsync();
if (response.IsSuccess)
{
Debug.Log($"Platform locale: {response.Data.locale}");
}
The returned locale code identifies the current platform language.
getLocaleBtn → On clicked
→ Call getLocale
When the locale is retrieved, the onLocaleLoaded function is triggered.
On function onLocaleLoaded
→ locale
The locale parameter contains the detected locale code.
Y8.getLocale(function(locale:String) {
if (locale == null) {
trace("Failed to get locale");
return;
}
trace("Game locale: " + locale);
});
The callback receives the detected locale code.
Supported Locales
The locale tells you which language the Y8 site your game is running on is
presented in — fr.y8.com gives fr. It is a good default for your own
language selection, and a better one than the browser's language, which often
disagrees with the site the player deliberately chose.
One of the following is returned:
ar Arabic |
bn Bengali |
da Danish |
de German |
el Greek |
en English |
es Spanish |
fa Persian |
fr French |
he Hebrew |
hi Hindi |
id Indonesian |
it Italian |
ja Japanese |
ko Korean |
mr Marathi |
nl Dutch |
no Norwegian |
pl Polish |
pt Portuguese |
ro Romanian |
ru Russian |
sv Swedish |
ta Tamil |
te Telugu |
th Thai |
tl Tagalog |
tr Turkish |
uk Ukrainian |
ur Urdu |
vi Vietnamese |
zh Chinese |
en is both a real answer and the fallback
Anything unrecognized returns en, and so does the main www site. You
cannot tell "the player is on the English site" apart from "we could not
tell" — treat en as a default rather than as a signal.
So use this to choose an initial language, and let the player change it. Do not use it to decide the player speaks English.
Using the Locale
Use the returned locale to select the appropriate language for your game.
For example:
```text locale = "en" → Use English
locale = "fr" → Use French
locale = "de" → Use German
locale = "ja" → Use Japanese