Opened 9 years ago
Closed 9 years ago
#25856 closed New feature (fixed)
JS strftime shim could (sometimes) support %B
Reported by: | Keryn Knight | Owned by: | Akos Zsolt Hochrein |
---|---|---|---|
Component: | Internationalization | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | django@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Currently, using the calendar widget in the admin, when the first DATE_INPUT_FORMATS
is %B %d, %Y
you end up outputting undefined 03, 2015
At a glance (and a monolingual one at that) I think it ought to be possible to shim support for %B
specifically in, at least sometimes; specifically, adding the following to admin/js/core.js:Date.prototype.strftime
:
var fields = { ... } if (typeof gettext !== "undefined" && typeof CalendarNamespace !== "undefined") { fields.B = CalendarNamespace.monthsOfYear[this.getMonth()] }
thus, if the javascript catalog (jsi18n
) is loaded, along with the calendar widget itself (calendar.js
), an additional shim is added for whatever the locale's full month name is.
Marked as as an internationalization issue because the format is locale specific. Vaguely relates to #25024 if you squint at it.
NB: for the purposes of suggestion, I've gone with attempting to access gettext
as a window global; it could instead test for window.gettext or django.gettext, I think.
Change History (6)
comment:1 by , 9 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 9 years ago
I'd recommend using something like this:
... Date.prototype.getFullMonthName = function() { return typeof CalendarNamespace === "undefined" ? this.getTwoDigitMonth() : CalendarNamespace.monthsOfYear[this.getMonth()]; }; ... Date.prototype.strftime = function(format) { var fields = { ... B: this.getFullMonthName(), ... }; ... };
comment:3 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 9 years ago
Has patch: | set |
---|
I guess if we have a patch, that will tell whether or not it's feasible. :-)