Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript culture always en-us
    primarykey
    data
    text
    <p>I'm not sure if I understand this code or if I'm using it right, but I was under the impression that in an ASP.NET 2.0 AJAX website I could run javascript like:</p> <pre><code>var c = Sys.CultureInfo.CurrentCulture </code></pre> <p>and it would give me the culture/language settings the user had specified in their browser at the time of the visit. However, for me, it always comes back 'en-US' no matter what language I pick in firefox or IE.</p> <p>This serverside code however:</p> <pre><code>string[] languages = HttpContext.Current.Request.UserLanguages; if (languages == null || languages.Length == 0) return null; try { string language = languages[0].ToLowerInvariant().Trim(); return CultureInfo.CreateSpecificCulture(language); } catch (ArgumentException) { return null; } </code></pre> <p>does return the language I have currently set. But I need to do this clientside, because I need to parse a string into a datetime and do some validations before I postback, and the string could be a MM/DD/YYYY or DD/MM/YYYY, or some other such thing.</p> <p>What am I missing?</p> <p>EDIT: Ok, I came across this library <a href="http://www.datejs.com/" rel="nofollow noreferrer">http://www.datejs.com/</a>. It looks pretty sweet, <em>and</em> it has ninjas, so I'm pretty much sold already. But in their doc I noticed that you need to include one of the language specific js files to include. I imagine you'd have to make that determination serverside and emit the proper script include tag, which got me thinking. Am I supposed to be doing this with the ASP.NET AJAX stuff? i.e. checking the serverside culture(which works) and setting the Sys.CultureInfo.CurrentCulture in js based on that? I was hoping it would just automagically get it from the browser clientside.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload