Opened 17 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: lawgon <lawgon@…> 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)

databrowse.diff (2.8 KB ) - added by Nick Efford 16 years ago.
New, refreshed version of the patch
databrowse2011.diff (2.8 KB ) - added by Dario Ocles 13 years ago.
patch updated to the last trunk

Download all attachments as: .zip

Change History (16)

comment:1 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedAccepted

I assume this is a generic i18n issue with databrowse?

comment:2 by lawgon <lawgon@…>, 17 years ago

same problem in polish - so it must be i18n generic issue

comment:3 by michal@…, 17 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 Simon G. <dev@…>, 17 years ago

Summary: when using finnish, databrowse with calendars does not translate the month back to english resulting in an errordatabrowse calendars do not translate the month back to english resulting in an error

comment:5 by msgre, 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 Fredrik Lundh <fredrik@…>, 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 Nick Efford, 17 years ago

Owner: changed from nobody to Nick Efford

comment:8 by Nick Efford, 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.

by Nick Efford, 16 years ago

Attachment: databrowse.diff added

New, refreshed version of the patch

comment:9 by Nick Efford, 16 years ago

I've updated the patch to be against a more recent trunk (post-nfa merge).

comment:10 by Adam Nelson, 14 years ago

Patch needs improvement: set

Patch needs to be updated to latest trunk ... again.

by Dario Ocles, 13 years ago

Attachment: databrowse2011.diff added

patch updated to the last trunk

comment:11 by Dario Ocles, 13 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 Dario Ocles, 13 years ago

Owner: changed from Nick Efford to Dario Ocles
Status: newassigned

comment:13 by Łukasz Rekucki, 13 years ago

Severity: Normal
Type: Bug

comment:14 by Preston Holmes, 13 years ago

Easy pickings: unset
Resolution: wontfix
Status: assignedclosed
UI/UX: unset

Databrowse is now deprecated, see #16907

Note: See TracTickets for help on using tickets.
Back to Top