Skip to content

Commit 9ac2fdf

Browse files
committed
Merge pull request #380 from python-babel/sils/2.3.1
2.3.2 release
2 parents d36f0fe + 41b7554 commit 9ac2fdf

File tree

5 files changed

+28
-3
lines changed

5 files changed

+28
-3
lines changed

CHANGES

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
Babel Changelog
22
===============
33

4+
Version 2.3.2
5+
-------------
6+
7+
(Bugfix release, released on April 9th)
8+
9+
Bugfixes
10+
~~~~~~~~
11+
12+
* Dates: Period (am/pm) formatting was broken in certain locales (namely zh_TW). Thanks to @jun66j5 for the bug report. (https://github.com/python-babel/babel/issues/378, https://github.com/python-babel/babel/issues/379)
13+
14+
Version 2.3.1
15+
-------------
16+
17+
(Bugfix release because of deployment problems, released on April 8th)
18+
419
Version 2.3
520
-----------
621

babel/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
negotiate_locale, parse_locale, get_locale_identifier
2222

2323

24-
__version__ = '2.3.1'
24+
__version__ = '2.3.2'

babel/dates.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,7 @@ def __getitem__(self, name):
12391239
elif char in ('E', 'e', 'c'):
12401240
return self.format_weekday(char, num)
12411241
elif char == 'a':
1242+
# TODO: Add support for the rest of the period formats (a*, b*, B*)
12421243
return self.format_period(char)
12431244
elif char == 'h':
12441245
if self.value.hour % 12 == 0:
@@ -1381,7 +1382,11 @@ def format_day_of_week_in_month(self):
13811382

13821383
def format_period(self, char):
13831384
period = {0: 'am', 1: 'pm'}[int(self.value.hour >= 12)]
1384-
return get_period_names(locale=self.locale)[period]
1385+
for width in ('wide', 'narrow', 'abbreviated'):
1386+
period_names = get_period_names(context='format', width=width, locale=self.locale)
1387+
if period in period_names:
1388+
return period_names[period]
1389+
raise ValueError('Could not format period %s in %s' % (period, self.locale))
13851390

13861391
def format_frac_seconds(self, num):
13871392
""" Return fractional seconds.

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
# The short X.Y version.
5454
version = '2.3'
5555
# The full version, including alpha/beta/rc tags.
56-
release = '2.3.1'
56+
release = '2.3.2'
5757

5858
# The language for content autogenerated by Sphinx. Refer to documentation
5959
# for a list of supported languages.

tests/test_dates.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,11 @@ def test_lithuanian_long_format():
742742
)
743743

744744

745+
def test_zh_TW_format():
746+
# Refs GitHub issue #378
747+
assert dates.format_time(datetime(2016, 4, 8, 12, 34, 56), locale='zh_TW') == u'\u4e0b\u534812:34:56'
748+
749+
745750
def test_format_current_moment(monkeypatch):
746751
import datetime as datetime_module
747752
frozen_instant = datetime.utcnow()

0 commit comments

Comments
 (0)