python-babel / babel

The official repository for Babel, the Python Internationalization Library
http://babel.pocoo.org/
BSD 3-Clause "New" or "Revised" License
1.29k stars 432 forks source link

[bug] Use standalone month name when month is standalone or give ability to chose #1065

Closed 07pepa closed 4 months ago

07pepa commented 4 months ago

Overview Description

CLDR is not used correctly. in some langue you call month diferently from when is in a date due declination when month is standalone name it is not localized into standalone variant.

see https://github.com/unicode-org/cldr/blob/9ffd5f7e749b838c67f5feaf85f67f9d1554303f/common/main/cs.xml#L4072 vs https://github.com/unicode-org/cldr/blob/9ffd5f7e749b838c67f5feaf85f67f9d1554303f/common/main/cs.xml#L4072

Steps to reproduce

from datetime import date, datetime, time
from babel.dates import format_date, format_datetime, format_time
dt = datetime(2007, 4, 1, 15, 30)
format_datetime(dt, "MMMM", locale="cs")

Actual Results

dubna

Expected Results

duben

Reproducibility

100 %

Additional Information

since month is standalone a standalone context should be used

akx commented 4 months ago

I think we're using CLDR correctly, using the format-context format for the component when formatting dates. If you can find official CLDR documentation saying that the stand-alone format for a component should be used when there's a single component in the format, I'll stand corrected.

If you need just the name of the month in any given context you like, you can use get_month_names() with e.g. context="stand-alone".

07pepa commented 4 months ago

ok that is good enough solution