[Django] #23568: timesince / timeuntil is not localized

8 views
Skip to first unread message

Django

unread,
Sep 29, 2014, 11:37:52 AM9/29/14
to django-...@googlegroups.com
#23568: timesince / timeuntil is not localized
--------------------------------------+------------------------
Reporter: lerela | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.7
Severity: Normal | Keywords: l10n, i18n
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------
When l10n/i18n are on, the `|timeuntil` and `|timesince` filters do not
provide translated strings.

I.e., with `end` a `datetime` object obtained with `timezone.now() +
timedelta(days=21)`:

{{{
{% load i18n l10n humanize %}

{% get_current_language as LANGUAGE_CODE %}
{{ LANGUAGE_CODE }}, {{ end }}, {{ end|timeuntil }}, {{ end|naturaltime
}}, {% trans "Password" %}
}}}

returns:
`es_ES, Oct. 20, 2014, 3:30 p.m., 2 weeks, 6 days, 2 weeks, 6 days a
partir de ahora, Contraseña`

So the localization is working, but those filters do not seem to use it.

See attached project for a working version of this example.

--
Ticket URL: <https://code.djangoproject.com/ticket/23568>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 1, 2014, 3:05:01 AM10/1/14
to django-...@googlegroups.com
#23568: timesince / timeuntil is not localized
-------------------------------------+-------------------------------------

Reporter: lerela | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.7
Internationalization | Resolution:
Severity: Normal | Triage Stage:
Keywords: l10n, i18n | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by mpessas):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Can you try using the "es" as language code in your settings instead of
es_ES? This is what django uses [1].

IIRC, gettext will fallback to English, if it cannot find the files that
correspond to the correct locale, which could explain the weird behavior
here.

The code looks correct to me with a quick look.

[1]: https://github.com/django/django/tree/master/django/conf/locale/es

--
Ticket URL: <https://code.djangoproject.com/ticket/23568#comment:1>

Django

unread,
Oct 1, 2014, 5:44:09 AM10/1/14
to django-...@googlegroups.com
#23568: timesince / timeuntil is not localized
-------------------------------------+-------------------------------------

Reporter: lerela | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.7
Internationalization | Resolution:
Severity: Normal | Triage Stage:
Keywords: l10n, i18n | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by lerela):

Same thing. The point of my example is that "regular" strings do get
translated (I don't have any project-specific locale file to translate
"password", this is Django's translation), so it is able to find the
locale files.

--
Ticket URL: <https://code.djangoproject.com/ticket/23568#comment:2>

Django

unread,
Oct 1, 2014, 5:52:38 AM10/1/14
to django-...@googlegroups.com
#23568: timesince / timeuntil is not localized
-------------------------------------+-------------------------------------
Reporter: lerela | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 1.7
Internationalization | Resolution: invalid

Severity: Normal | Triage Stage:
Keywords: l10n, i18n | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by lerela):

* status: new => closed
* resolution: => invalid


Comment:

Turned out I did not realize I was still using RC2. 1.7 does not have this
bug, even though I don't know when/where it has been solved. Sorry.

--
Ticket URL: <https://code.djangoproject.com/ticket/23568#comment:3>

Reply all
Reply to author
Forward
0 new messages