Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#14570 closed (fixed)

New format character to represent locale-specifc alternative month names

Reported by: shell_dweller Owned by: nobody
Component: Internationalization Version: master
Severity: Keywords: month, format
Cc: s.kuzmenko@…, claude@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Why this is required

In certain locales "F" is not enough to represent full month name in long date formats. The reason is that "F Y" (e.g., "October 2010") and "F j Y" (e.g., "October 1 2010") will require two different grammatical forms for month name.

This patch is useful for Greek and the majority of Slavic languages. Other languages may find use of it too.

Solution

New format character is introduced to represent alternative locale specific month names. The choice of character is "E". Rationale: alphabetically it is the closest one to "F" that represents full month name.

TODO

After this patch is committed to trunk I will create a patch for documentation and will notify translators.

Historical note

This is a duplicate of ticket 12309 that was created and subsequently closed by me. At the time I reckoned that it would be better to use Babel for locale specific date representations. However, after careful consideration I changed my mind and I do believe this is a useful addition to Django because it follows batteries included principle, specially in view of new format localization rules introduced in 1.2

Attachments (2)

alternative-long-date-format.diff (3.3 KB) - added by shell_dweller 4 years ago.
A better patch based on pgettext
alternative-month-name-localizations.diff (12.7 KB) - added by shell_dweller 4 years ago.
A clean translation patch (translations were loaded from Babel based on LDML definitions)

Download all attachments as: .zip

Change History (7)

comment:1 Changed 4 years ago by claudep

  • Cc claude@… added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I have some doubt about the "_Month" syntax used in your patch. We are currently working on pgettext support in ticket #9988. If it gets committed, you would then be able to take advantage of the new pgettext function to obtain amore standard contextual marker. More generally, I'm still a little worried by the extra strings you add even for languages that do not use the feature, but I don't see any other/better method to achieve the same goal.

comment:2 Changed 4 years ago by shell_dweller

Suggestion to use pgettext instead of "_Month" makes good sense. I will adjust my patch accordingly.

I do share the concern about introducing extra format character that is going to be used only by a limited number of locales. So for the record here's how this is done elsewhere:

POSIX has no notion of "alternative month". Instead, there is a special conversion specification modifier (%O) that is used to represent alternative numbers (probably with languages such as Persian in mind). This is commonly used as a work around when an alternative month name representation is required.

In Babel based on LDML specification various alternative representations of month names are achieved by character repetition, e.g., "MMMM" is usually the "alternative" month representation I'm talking about here. Note that there are two format characters for month: "L" (stand alone which would be an equivalent of what "F" is currently in Django) and a more generic "M" format (which would be an equivalent of my proposed "E" format).

So basically this leaves us with two major options:

  1. Introduce a new format character
  1. Use some sort of extended notation (either though a modifier character of mere repetition)

The benefit of 1 is simplicity of implementation (and use). Option 2 requires more significant changes to the date formatting engine but is potentially more robust (e.g., can be easily extended towards alternative numeric representations for month, day, hour and so on without introduction of new format characters).

Yet another option would be to adopt LDML notation with gradual phasing out the existing PHP based notation which is not particularly i18n friendly. This would be the most dramatic change of course.

It would be very nice to get some feedback form the core team on this subject before I commit to providing my final patch.

Changed 4 years ago by shell_dweller

A better patch based on pgettext

Changed 4 years ago by shell_dweller

A clean translation patch (translations were loaded from Babel based on LDML definitions)

comment:3 Changed 4 years ago by jezdez

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

(In [14899]) Fixed #14570 -- Added new date format character for alternative month names using the new context capabilities. Also add context to Associated Press style month names (refs #9988). Thanks to Claude and shell_dweller.

comment:4 Changed 4 years ago by jezdez

(In [14900]) Updated date format strings of languages that require alternate month names. Refs #14570 because it uses the new format character added for this purpose. Thank you, shell_dweller.

comment:5 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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.