Code

Opened 6 years ago

Closed 4 years ago

Last modified 2 years ago

#9366 closed Uncategorized (fixed)

date and time filters do not use localized strings, missing datetime filter

Reported by: bthomas Owned by: garcia_marc
Component: Internationalization Version: 1.0
Severity: Normal Keywords: i18n-fixed
Cc: Triage Stage: Fixed on a branch
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The date and time filters do not use localized/translated strings for the default format. The admin interface uses get_date_formats, which checks for a translation first, then falls back to settings.DATE_FORMAT, etc.

Also, a filter that defaults to DATETIME_FORMAT is missing, and would be a nice shortcut.

Attachments (1)

datefilters.diff (1.6 KB) - added by bthomas 6 years ago.
Use translated strings for date/time formats, add a datetime filter

Download all attachments as: .zip

Change History (14)

Changed 6 years ago by bthomas

Use translated strings for date/time formats, add a datetime filter

comment:1 Changed 6 years ago by mtredinnick

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

One item per ticket, please. You're both trying to report a bug and add a new feature here. I suspect the new feature probably won't go in, since you can already format datetimes with the date filter and we should just the right default there (whatever that is).

So please split out the new feature bit from this patch so the bugfix can be considered in isolation (it also will need a test). If you want to open a new ticket for the new feature, that's fine and it can then be looked at in due course.

comment:2 Changed 6 years ago by bthomas

  • Component changed from Uncategorized to Internationalization

I think this is somewhat related to #2203 (the bug part of it, anyway). However that ticket is fixed will affect this, since the admin interface's date display should be consistent with the date filters.

comment:3 Changed 5 years ago by Daniel Pope <dan@…>

@mtreddinick: This isn't really two items. This ticket is about the fact that there's no way of using the existing datetime localisation (http://code.djangoproject.com/browser/django/trunk/django/utils/translation/trans_real.py#L396) in templates.

It makes sense to have the date and time filters do this if the i18n machinery is enabled - otherwise these filters are just about useless in internationalised applications. However, it's not sufficient to just have date and time filters, as the preferred format for combined time and date in different cultures may vary independently from date, time or any combination of the two, so the solution also necessitates a datetime filter. It's a two-part solution, not two different problems.

Anyway, FWIW, this is exactly what I need for the site I'm developing at the moment.

comment:4 Changed 5 years ago by mtredinnick

It is about two items. Item #1 is the first paragraph of the description. Item #2 is the second paragraph. The second one is a feature request and is independent of the first part.

comment:5 Changed 5 years ago by Daniel Pope <dan@…>

The second part is not independent. Imagine a culture that writes date as dd/mm/yyyy but date and time as dd/mm hh:mm yyyy. Whether any such culture exists I don't know, but an internationalisable datetime formatting system should be able to cope with this.

comment:6 Changed 5 years ago by mtredinnick

You are simply saying that the second feature is necessary. Not that it is entirely and unrevocably part of the first bug fix. It will be quite possible to fix the first part without adding the second part. They are separable. This isn't a question of value.

In any case, this is going around and around. The internationalisation fix will be done as part of a larger ticket. At that point, somebody can update this with a fix to add the missing bit.

comment:7 Changed 5 years ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

comment:9 Changed 5 years ago by anonymous

  • Cc hv@… added

comment:10 Changed 5 years ago by garcia_marc

  • Keywords i18n-fixed added
  • Owner changed from nobody to garcia_marc

comment:11 Changed 5 years ago by garcia_marc

  • Triage Stage changed from Accepted to Fixed on a branch

comment:12 Changed 4 years ago by jezdez

  • Resolution set to fixed
  • Status changed from new to closed

(In [11964]) Fixed #7980 - Improved i18n framework to support locale aware formatting (dates and numbers) and form processing.

Thanks to Marc Garcia for working on this during his Google Summer of Code 2009!

Additionally fixes #1061, #2203, #3940, #5526, #6449, #6231, #6693, #6783, #9366 and #10891.

comment:13 Changed 2 years ago by guettli

  • Cc hv@… removed
  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.