Noctua Platform
Platform Locale
Noctua Platform handle the locale of the user. So you can refer the best locale for your game based on user's preference
How to get the platform locale?
string language = Noctua.Platform.Locale.GetLanguage();
string country = Noctua.Platform.Locale.GetCountry();
string currency = Noctua.Platform.Locale.GetCurrency();
Change language
To be able to sync language change between game and SDK, Noctua SDK provide Locale.SetUserPrefsLanguage() method and Locale.OnLanguageChanged event. Below is example on how to use it in code:
User could change the language from the SDK UI and the game can get the new language by using these two APIs:
// Get language
var lang = Noctua.Platform.Locale.GetLanguage();
var changedLang = lang;
// Subscribe to OnLanguageChanged event
Noctua.Platform.Locale.OnLanguageChanged += l => changedLang = l;
User could also change the language from the game UI and the game need to tell the SDK if the language has been changed:
// Change language
var newLang = lang switch
{
"id" => "vi",
_ => "id"
};
Noctua.Platform.Locale.SetUserPrefsLanguage(newLang);
// OnLanguageChanged is raised
Assert.AreEqual(newLang, changedLang);