Opened 6 years ago

Closed 5 years ago

#12309 closed (duplicate)

New format character to represent alternative locale-specifc month names

Reported by: shell_dweller Owned by: shell_dweller
Component: Internationalization Version:
Severity: Keywords: date, template, i18n
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: UI/UX:

Description

I would like to suggest (and claim responsibility for) an extension for date format to handle alternative (locale specific) months names.

Why is this needed?

Alternative months names would have no universal meaning but would allow an additional flexibility with date display in certain languages.

For example, in some Slavic languages (Polish, Ukrainian, Russian and likely few others) phrases “January 2010” and “January 1 2010” would require two distinct grammatical forms: nominative in the first case and genitive in the second. To represent phrases with month names in the genitive case one would use the alternative month names.

How to represent it

I have no particular preference. “E” seems to be a reasonable choice because it stands next to “F” in the alphabet and “F” in used in Django to represent long month names.

Implementation

Coding for this feature is trivial. But I will need to cooperate with language translators to add translations to certain locales.

Attachments (1)

django-12309.diff (1.8 KB) - added by shell_dweller 6 years ago.
Just the code patch, without .po files

Download all attachments as: .zip

Change History (11)

comment:1 Changed 6 years ago by shell_dweller

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to shell_dweller
  • Patch needs improvement unset
  • Status changed from new to assigned

comment:2 Changed 6 years ago by shell_dweller

  • Has patch set
  • Resolution set to fixed
  • Status changed from assigned to closed

Change summary (patch explanation)

Added new date format character "E" to cater to specific locales where "F" is not enough. Updated Russian and Ukrainian translation files to be able to use the new format.

Sample usage

Format "j E Y" will produce outputs similar to the following:

  • in Russian: "5 декабря 2009"
  • in Ukrainian: "5 грудня 2009"

Here month names are grammatically correct in genitive instead of nominative as generated by "F".

Further actions

If the patch is committed I will go ahead and will update documentation. I will also notify i18n list. Other locales may benefit from this as well (I know that Polish uses the same grammatical construction for full dates).

comment:3 Changed 6 years ago by shell_dweller

  • Resolution fixed deleted
  • Status changed from closed to reopened

comment:4 Changed 6 years ago by orestis

You may be interested in the approach defined in http://code.google.com/p/django-localdates/

When I opened a similar bug 2 years ago, it was rejected on the grounds of not adding new formats willy nilly. It makes some sense. A more extensible mechanism could be more useful down the road.

comment:5 Changed 6 years ago by orestis

For reference, the old ticket is #4147

comment:6 Changed 6 years ago by shell_dweller

Looking at Orestis' implementation it seems to me that it is modelled on a 3 case system of the Greek language. But in Russian there are 6 cases! With this implementation it is impossible to generate correct Russian phrases such as "by December 2009" or "from March to April". I doubt it is even possible to create a generic framework for outputting month names in any given language.

Changed 6 years ago by shell_dweller

Just the code patch, without .po files

comment:7 Changed 6 years ago by shell_dweller

  • milestone 1.2 deleted
  • Resolution set to wontfix
  • Status changed from reopened to closed

After having done some research I found out that the best way to achieve this would be to use Babel which also provides a handful of Django template tags (http://babel.edgewall.org/wiki/BabelDjango).

comment:8 Changed 5 years ago by anonymous

  • Resolution wontfix deleted
  • Status changed from closed to reopened

In django-1.2 we have new l10n and i18n system, so there is no need of Babel. So, maybe you can give another chance to this feature?

comment:9 Changed 5 years ago by jezdez

  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

With the recent addition of context aware translation we can solve this easier.

comment:10 Changed 5 years ago by anonymous

  • Resolution set to duplicate
  • Status changed from reopened to closed

This was fixed in #14570. Closing as duplicate.

Note: See TracTickets for help on using tickets.
Back to Top