Call up system language

Oct 22, 2020

I have 2 pages in Storyline, one in German, the other in English. I would like to query the system language via script and then display the corresponding page via trigger. Is that possible?

5 Replies
Math Notermans

The system language as is is not selectable in all browsers. As far as i know only in IE you can find the system language.

However you can find the user preferred browser language. That doesnot is the same as the system language. Users can have a preferred browser lang that differs from his/her system language. And its not fool proof because a user can change that anytime.

That said... this javascript code detects the browser language...

//detect the language preference of the user's browser
var userLanguage = window.navigator.userLanguage || window.navigator.language;

console.log("language is: "+userLanguage );
alert("language is: "+userLanguage);

I tested this in Chrome only.


Kind regards,
Math



Math Notermans

Hi Enrique,

The variable is now in Javascript set... so userLanguage is a Javascript variable... as is Storyline cannot do much with that.

To assign any given value to a Storyline variable you need to create them in your SL project...
Say your SLvar is 'browserLang'...

You first need to target the SL player...
var player = GetPlayer();

then you can get the variables at will...
player.GetVar("browserLang");

or set the variables at will...
player.SetVar("browserLang",userLanguage);

Added a working sample....

Kind regards,
Math

OWEN HOLT
Math Notermans

That said... this javascript code detects the browser language...

//detect the language preference of the user's browser
var userLanguage = window.navigator.userLanguage || window.navigator.language;

console.log("language is: "+userLanguage );
alert("language is: "+userLanguage);

I tested this in Chrome only.

Just tested in IE and Edge. Works in both.

This discussion is closed. You can start a new discussion or contact Articulate Support.