Opened 8 years ago

Closed 3 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: burzak
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 nickefford 7 years ago.
New, refreshed version of the patch
databrowse2011.diff (2.8 KB) - added by burzak 4 years ago.
patch updated to the last trunk

Download all attachments as: .zip

Change History (16)

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

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

I assume this is a generic i18n issue with databrowse?

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

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

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

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

comment:5 Changed 7 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 7 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 7 years ago by nickefford

  • Owner changed from nobody to nickefford

comment:8 Changed 7 years ago by nickefford

  • 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 7 years ago by nickefford

New, refreshed version of the patch

comment:9 Changed 7 years ago by nickefford

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

comment:10 Changed 5 years ago by adamnelson

  • Patch needs improvement set

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

Changed 4 years ago by burzak

patch updated to the last trunk

comment:11 Changed 4 years ago by burzak

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 4 years ago by burzak

  • Owner changed from nickefford to burzak
  • Status changed from new to assigned

comment:13 Changed 4 years ago by lrekucki

  • Severity set to Normal
  • Type set to Bug

comment:14 Changed 3 years ago by ptone

  • Easy pickings unset
  • Resolution set to wontfix
  • Status changed from assigned to closed
  • UI/UX unset

Databrowse is now deprecated, see #16907

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