Opened 10 years ago

Closed 5 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: master
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 8 years ago.
New, refreshed version of the patch
databrowse2011.diff (2.8 KB) - added by Dario Ocles 6 years ago.
patch updated to the last trunk

Download all attachments as: .zip

Change History (16)

comment:1 Changed 10 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedAccepted

I assume this is a generic i18n issue with databrowse?

comment:2 Changed 10 years ago by lawgon <lawgon@…>

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

comment:3 Changed 10 years ago by michal@…

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 Changed 9 years ago by Simon G. <dev@…>

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 Changed 9 years ago by msgre

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 Changed 9 years ago by Fredrik Lundh <fredrik@…>

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 Changed 9 years ago by Nick Efford

Owner: changed from nobody to Nick Efford

comment:8 Changed 9 years ago by Nick Efford

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.

Changed 8 years ago by Nick Efford

Attachment: databrowse.diff added

New, refreshed version of the patch

comment:9 Changed 8 years ago by Nick Efford

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

comment:10 Changed 7 years ago by Adam Nelson

Patch needs improvement: set

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

Changed 6 years ago by Dario Ocles

Attachment: databrowse2011.diff added

patch updated to the last trunk

comment:11 Changed 6 years ago by Dario Ocles

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 Changed 6 years ago by Dario Ocles

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

comment:13 Changed 6 years ago by Łukasz Rekucki

Severity: Normal
Type: Bug

comment:14 Changed 5 years ago by Preston Holmes

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