api.jqueryui.com icon indicating copy to clipboard operation
api.jqueryui.com copied to clipboard

Datepicker Widget Utility functions: $.datepicker.regional[ "fr" ] is not defined by default

Open Chealer opened this issue 10 years ago • 3 comments

http://api.jqueryui.com/datepicker/ contains the following code example:

Set all date pickers to have French text. 1 $.datepicker.setDefaults( $.datepicker.regional[ "fr" ] );

In reality, this only works if $.datepicker.regional[ "fr" ] is defined, and defined to contain French texts. As explained in the Localization section (below), this typically involves loading an extra JS file.

Note that the files on jQuery's GitHub already call setDefaults, so for a French-only website, that call would be unneeded.

Also, the description is misleading; $.datepicker.regional[ "fr" ] contains options not limited to labels. For example, it sets dateFormat. I recommend either clarifying the effect or removing this example.

By the way, I wonder whether the Localization section shouldn't be above the Utility functions section, since by default, the widget is difficult to use unless all of the audience understands English.

Chealer avatar Jul 23 '15 01:07 Chealer

Are you suggesting that we add a note that you must load the locale first? It's not entirely clear exactly what change you're looking for.

scottgonzalez avatar Jul 23 '15 05:07 scottgonzalez

Hi Scott, I am also not entirely clear on what exactly should be done myself. What is important is to make sure the reader does not believe the call will necessarily localize to French, and I will consider this ticket as solved no matter which solution addresses that. This could indeed be adressed by adding a note, or simply by removing the example.

I think treating $.datepicker.setDefaults( $.datepicker.regional[ foo ] ); is important. But this should probably be done in the Localization section. It is in fact almost done there already.

There is a cost to keeping the example, even in a non-misleading form. $.datepicker.regional is never defined. For a relatively inexperienced user like me, the call is puzzling - it is not clear that $.datepicker.regional[ foo ] corresponds to $options.

So, at least with a small adaptation of the Localization section, I believe the best solution is removal.

Chealer avatar Jul 23 '15 12:07 Chealer

I agree with @Chealer . Localisation should a first citizen in the option list and not require any other js loading. The calendar should come with a default option en_US and users should be able to change on the fly the locale as any other option within the options set.

valugi avatar Oct 19 '18 14:10 valugi