Skip to main content

Search and Top Navigation

#15128 closed bug (notabug)

Opened January 14, 2017 10:43AM UTC

Closed January 14, 2017 12:38PM UTC

Last modified January 15, 2017 09:56AM UTC

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.regional['xy']);

Wouldn't it be better to take "en" as default, if an invalid locale is given? I currently have to do this manually.

Attachments (0)
Change History (2)

Changed January 14, 2017 12:38PM UTC by scottgonzalez comment:1

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.

Changed January 15, 2017 09:56AM UTC by claudi comment:2

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 ;)