Can you get culture info string in javascript just like in .NET?

Tomasz Sikora picture Tomasz Sikora · Dec 11, 2013 · Viewed 18.6k times · Source

I need to get culture string from browser's language.

I thought about getting it from javascript like this:

var userLang = navigator.language || navigator.userLanguage;

but it gives me only first part of culture info that i would get from .NET:

Thread.CurrentThread.CurrentCulture.Name;

So javascript gives me "de" or "pl" instead of "de-DE" or "pl-PL" like in .NET. Is there a way to get the "full info" ?

Answer

DaImTo picture DaImTo · Dec 11, 2013

try this

<script>
var cultureInfo = '@System.Globalization.CultureInfo.CurrentCulture.Name';
</script>