Opened 12 years ago
Closed 12 years ago
#10993 closed defect (fixed)
Day names header is garbled with `Accept-Language: ja`
Reported by: | Jun Omae | Owned by: | Steffen Hoffmann |
---|---|---|---|
Priority: | normal | Component: | WikiCalendarMacro |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.12 |
Description (last modified by )
When browser sends Accept-Language: ja
, WikiCalendarMacro renders garbled header in the calendar.
- CentOS 5.9
- Python 2.4
- Trac 0.12.5
- tracd
- WikiCalendarMacro r12844
Request headers:
GET /wiki/SandBox/WikiCalendarMacro HTTP/1.1 Host: localhost:3000 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: ja,en-us;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate DNT: 1 Cookie: auth_sess=3bbf3b909d6b22263a27589ac10a5b982694efd3; trac_form_token=af700c16ee5b5954f9430684; trac_auth=826fd3482f6220360de2c655d04e8fda Authorization: Digest username="foobar", realm="auth", nonce="571817734d427a974703a57ce65da867", uri="/wiki/SandBox/WikiCalendarMacro", response="6f87d9dd77b4351e53f0c96408efc4de", qop=auth, nc=00000152, cnonce="17b7a21e4253ce7a" Connection: keep-alive
Response headers:
HTTP/1.1 200 OK Server: tracd/0.12.5 Python/2.4.3 Date: Sun, 31 Mar 2013 06:24:20 GMT Cache-Control: must-revalidate Expires: Fri, 01 Jan 1999 00:00:00 GMT Content-Type: text/html;charset=utf-8 Content-Length: 14444
From trac.log;
... 03:15:43 PM Trac[util] DEBUG: args: ('wiki', u'SandBox/WikiCalendarMacro') 03:15:43 PM Trac[util] DEBUG: prefetch: 0 rows 03:15:43 PM Trac[formatter] DEBUG: Executing Wiki macro WikiCalendar by provider <wikicalendar.macros.WikiCalendarMacros object at 0xa96340c> 15��15ʬ43�� Trac[macros] DEBUG: Locale setting for calendar: ja_JP.eucJP ...
At least, should use ja_JP.UTF8
instead of ja_JP.eucJP
.
Attachments (1)
Change History (7)
Changed 12 years ago by
Attachment: | ja-WikiCalendarMacro.png added |
---|
comment:1 Changed 12 years ago by
Description: | modified (diff) |
---|
comment:2 follow-up: 3 Changed 12 years ago by
comment:3 Changed 12 years ago by
Replying to jun66j5:
locale.getlocale()
returns language code, encoding as tuple. The encoding is able to use for unicode decoding.
Thanks for the suggestion, even if #10992 suggests it might be only an intermediate solution.
Regarding the calendar header constructor I've felt the old code was sub-optimal, but couldn't do better. Using a test result as index looks much more elegant indeed.
You proposed patch made me think about another possible aspect of customization: number of workdays per week. It must have felt as natural to you to set weekend == Sunday as it does to me to set it according to the two-days-weekend like done by the replaced code. Number of weekdays matters especially for ticket calendar due to different column widths. This is in CSS, hence it's not so flexible.
comment:4 Changed 12 years ago by
comment:5 Changed 12 years ago by
(In [12951]) WikiCalendarMacro: Switch from Python core modules calendar
and locale
towards using Babel by default, refs #10992 and #10993.
This is the bare minimum of changes, that don't break code, but turn Babel into an undeclared, strict requirement so far. I'll fix that later. Starting to remove class attribute variables for becoming thread-safe again.
comment:6 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
(In [12991]) WikiCalendarMacro: Releasing current, tested macro package as final product, closes #7639, #8175, #9718, #10991, #10992 and #10993.
Special thanks to Jun Omae for pushing development by testing and providing valuable hints in our discussion about utilizing Babel for better localization and for making macro execution thread-safe as well.
locale.getlocale()
returns language code, encoding as tuple. The encoding is able to use for unicode decoding.wikicalendar/macros.py
for day in calendar.weekheader(2).split()[-2:]:col = tag.th(to_unicode(day))col(class_='weekend', scope='col')heading(col)