views:

335

answers:

2

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
+3  A: 

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.

Patrick H. Lauke
3 problems with that: 1. It is jarring as a user to have to switch languages (chrome vs content) for a date picker. 2. The data will be rendered to the page in a locale, will the chrome (in English mode) understand the French and that Juin means June? 3. Server side will expect data formatted in a locale and parse accordingly, if the date picker does format the date for the expected locale, the server will misinterpret it.These problems are not limited to dates. What about numbers? French uses a comma instead of a decimal. How will the chrome handle that?The approach seems short sighted.
lambacck
1 it acts like, say, the file type input in all browsers...that also localises according to the browser locale, not the page. i can see arguments for and against this.2 don't quite get what you mean here-assuming this relates to 3 regardless of how the UI for the datepicker is displayed, the end result (which is then passed to the server) is always in the same ISO format, regardless of the language shown by the UI. not tried the numbers thing (assuming you mean input type="number")...but here i can see that it would indeed have potential issues. don't know if that's localised currently, tho.
Patrick H. Lauke
I don't think that ISO format is reasonable response for progressive enhancement. If the browser falls back to a plain input box and they don't have Javascript enabled (yes those people exist) they will then have to enter the date in ISO format? If the user is non-technical, it is unlikely that they will want to enter the date in ISO format (even know how).
lambacck
A: 

Hi,

I agree with lambacck. Currently I am writing Javascript code to make the new form features available cross browser, using jQuery UI for this.

I work in Luxemburg which is a good place to illustrate the localization problem in more detail.

Most websites we write are multilingual de|fr|en. From our stats we can tell, that people use the language switch on the site to display their preferred language, but this choice rarely matches the preferred browser locale.

If the locale of the calendar etc. field is done by the OS, this brings us back to the unfortunate <input type=file> situation where the label reads Upload a file and the button says Parcourir. You can do nothing about this language mix and I always found this to be a major annoyance.

Conclusion, I have to overwrite the default calendar with the jQuery one to be sure it does what I want.

In my opinion a configurable API or at least a way to manipulate the locale on a HTML level would be great. Since the new field types are not widely adopted yet by the other browser manufacturers, I imagine this issue could still be taken in account.

Thanks for reading this.

Dieter Raber