Access Language other than Current?

More
8 years 2 months ago #1732 by Ray
Is there a way to access a string from a language that is not the current language?

For example:
string englishText = I2.Loc.ScriptLocalization.Get("MyKEY", "en");

The use case is that I sometimes want to use an English string regardless of the player's locale -- not to be shown to the user but for things like recording analytics where I'd like to send events with English object names. (It's easy enough to work around this... just curious if there's an easy way to access it that I'm not finding.)

Please Log in or Create an account to join the conversation.

More
8 years 2 months ago #1733 by Frank
You can use the GetTermData function to get the full term description, then access the language you need:
TermData data = I2.Loc.LocalizationManager.GetTermData("MyKey");
int LanguageIndex = I2.Loc.LocalizationManager.Sources[0].GetLanguageIndex("English");
string englishText = data.Languages[ languageIndex].

if you set your first language to be english, then its even simpler:
string englishText = I2.Loc.LocalizationManager.GetTermData("MyKey").Languages[0].

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
The following user(s) said Thank You: Ray

Please Log in or Create an account to join the conversation.

Time to create page: 0.127 seconds
Template by JoomlaShine