Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#15128 closed bug (notabug)

datepicker default localisation chinese

Reported by: claudi Owned by:
Priority: minor Milestone: none
Component: ui.datepicker Version: 1.12.1
Keywords: Cc:
Blocked by: Blocking:

Description

If you set an invalid locale to datepicker, it switches to chinese language. I.e. $.datepicker.setDefaults($.datepicker.regionalxy?); Wouldn't it be better to take "en" as default, if an invalid locale is given? I currently have to do this manually.

Change History (2)

comment:1 Changed 2 years ago by Scott González

Resolution: notabug
Status: newclosed

Let me explain what's happening. You are not setting an invalid locale, you are passing undefined to setDefaults(). setDefaults() does not accept a locale, it accepts an object containing settings which should become the new defaults. When you use an invalid locale, you're indexing into $.datepicker.regional on a key that doesn't exist and getting back undefined. You're then passing undefined to setDefaults() which does nothing. The only reason you'd be getting Chinese at that point is because the defaults are already set to Chinese before this call. Keep in mind that every locale file you load changes the defaults.

comment:2 Changed 2 years ago by claudi

Thanks for the explanation. I think it's ok to use the workaround checking for undefined. I was always wondering about getting chinese so nice to know the reason for this ;)

Note: See TracTickets for help on using tickets.