Is there a way to localize input type="date" in HTML5

lambacck picture lambacck · Jun 3, 2010 · Viewed 33.4k times · Source

I know that at the time of this writing only Opera supports a browser UI for

<input type="date" name="mydate">

and maybe my attempts to localize this field have been met with frustration because niceties like localization have not yet been included in their implementation, but I don't even see mention of it in the HTML5 spec. Is there a way that localization should be specified? Should I do lang="fr" on a parent element?

Some notes on the implementation of the site in question:

  • Localization (language) is explicitly picked by the user because they are managing data in multiple languages and it is not reasonable to expect that the user's browser chrome is in the language being viewed or that the browser is providing desired language request headers.
  • I want to be sure that if the page is rendered in French that the date picker provided by browser chrome shows options that make sense for French language.
  • The plan is to fall back to jQueryUI for browsers that do not support type="date", I will use the detection mechanism provided in Dive into HTML 5

Answer

Patrick H. Lauke picture Patrick H. Lauke · Jun 3, 2010

From what i know, the thinking behind what we do in Opera (full disclosure: I work for them) is that the date picker is almost an extension of the chrome, a browser-native control. As such, it will be localised according to the language of the browser, rather than the language of the page being viewed.