Opened 18 years ago
Closed 13 years ago
#4094 closed Bug (wontfix)
databrowse calendars do not translate the month back to english resulting in an error
Reported by: | Owned by: | Dario Ocles | |
---|---|---|---|
Component: | contrib.databrowse | Version: | dev |
Severity: | Normal | Keywords: | sprintsept14 |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
When using databrowse in english, on selection of a year, the months are given. The url for clicking on a month would be ~/1998/feb/. This works. In finnish, on clicking the equivalent of february, the url becomes ~/1998/hel/ where 'hel' are the first three letters of the finnish equivalent of february. This obviously doesnt work.
Attachments (2)
Change History (16)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:3 by , 18 years ago
Same in Czech language.
I looked into Django code and found, that calendar generate URLs with
month presented as 3-letters text. And that is propably the reason of
404 page -- in my language I get ugly URLs like:
http://127.0.0.1:8000/databrowse/news/new/calendars/created/2007/b%C5%99e/
http://127.0.0.1:8000/databrowse/news/new/calendars/created/2007/z%C3%A1%C5%99/
It is not so common approach to represent month as 3-letter shortcuts in
my country. In this situation will be better to represent month as
number, ie:
http://127.0.0.1:8000/databrowse/news/new/calendars/created/2007/03/
http://127.0.0.1:8000/databrowse/news/new/calendars/created/2007/09/
In django/views/generic/date_based.py I found, that archive_month
function have parameter month_format, but calendar_view (in
django/contrib/databrowse.plugins/calendar.py) leave it to default value
(%b).
Is it possible change the code to generate months in URLs as numbers,
instead of 3-letter texts please?
comment:4 by , 17 years ago
Summary: | when using finnish, databrowse with calendars does not translate the month back to english resulting in an error → databrowse calendars do not translate the month back to english resulting in an error |
---|
comment:5 by , 17 years ago
I try to solve it, but I am stuck, sorry.
What I found: I think, that problem is in strptime
function (for example in django/views/generic/date_based.py
line 119).
First, it is necessary to set correct locale. Next, if strptime gets date string as unicode, it throw exception UnicodeDecodeError. But, if I put there same string, but not as unicode it is successfull:
import locale locale.setlocale(locale.LC_TIME, 'cs_CZ.UTF-8') from time import strptime strptime(u'2007kvě', '%Y%b') # this throw UnicodeDecodeError exception strptime('2007kvě', '%Y%b') # this is OK (see, date string isn't unicode, but it contain unicode character)
comment:6 by , 17 years ago
Should the URI really used localized names? Wouldn't numbers or english names be more robust?
(the Unicode issues for CZ is different from the original case for FI, but a non-localized fix would solve both, I think).
comment:7 by , 17 years ago
Owner: | changed from | to
---|
comment:8 by , 17 years ago
Has patch: | set |
---|---|
Keywords: | sprintsept14 added |
I'm submitting a patch that fixes this by using numeric months in the URLs, as suggested by michal & fredrik. The patch also fixes a bug in the heading displayed by the calendar_month.html
template.
comment:9 by , 16 years ago
I've updated the patch to be against a more recent trunk (post-nfa merge).
comment:10 by , 15 years ago
Patch needs improvement: | set |
---|
Patch needs to be updated to latest trunk ... again.
comment:11 by , 14 years ago
I updated to the latest trunk. I just aplied the same changes and the last patch. This is my first contribution so sorry if I make some mistake.
comment:12 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:13 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:14 by , 13 years ago
Easy pickings: | unset |
---|---|
Resolution: | → wontfix |
Status: | assigned → closed |
UI/UX: | unset |
Databrowse is now deprecated, see #16907
I assume this is a generic i18n issue with databrowse?