If navigator.language
returns en-US
, but I only want en
because I don't care about the locale
, is there a preferred way to do this? Does angular have anything built in for this or should I just split on the -
?
If navigator.language
returns en-US
, but I only want en
because I don't care about the locale
, is there a preferred way to do this? Does angular have anything built in for this or should I just split on the -
?
2 Answers
Reset to default 7use js String.prototype.slice()
method.
navigator.language.slice(0,2);
This will do:
navigator.language.substring(0,2);