[Django] #29944: Can't translate URL if activated language is different than the URL's

8 views
Skip to first unread message

Django

unread,
Nov 11, 2018, 2:33:03 PM11/11/18
to django-...@googlegroups.com
#29944: Can't translate URL if activated language is different than the URL's
------------------------------------------------+------------------------
Reporter: Pacu2 | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 2.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
What I'm trying to achieve:
- Translate English URL to a different language, when activated language
is different than English

{{{
from django.urls import translate_url
from django.utils.translation import activate

url = '/en/'

# Translating english url with german language activated fails
activate('de')
print(translate_url(url, 'de')) # '/en/'

# Works just fine with english language activated
activate('en')
print(translate_url(url, 'de')) # '/de/'
}}}

Not sure if this ticket is valid as `translate_url` is not documented by
the official docs, might be I'm using it wrongly?

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

Django

unread,
Nov 11, 2018, 3:09:10 PM11/11/18
to django-...@googlegroups.com
#29944: Can't translate URL if activated language is different than the URL's
-------------------------------------+-------------------------------------

Reporter: Pacu2 | Owner: nobody
Type: Bug | Status: new
Component: | Version: 2.1
Internationalization |
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Pacu2:

Old description:

> What I'm trying to achieve:
> - Translate English URL to a different language, when activated language
> is different than English
>
> {{{
> from django.urls import translate_url
> from django.utils.translation import activate
>
> url = '/en/'
>
> # Translating english url with german language activated fails
> activate('de')
> print(translate_url(url, 'de')) # '/en/'
>
> # Works just fine with english language activated
> activate('en')
> print(translate_url(url, 'de')) # '/de/'
> }}}
>
> Not sure if this ticket is valid as `translate_url` is not documented by
> the official docs, might be I'm using it wrongly?

New description:

What I'm trying to achieve:
- Translate English URL to a different language, when activated language
is different than English

Setup:
Everything as per docs in
https://docs.djangoproject.com/en/1.11/topics/i18n/translation/#module-
django.conf.urls.i18n

{{{
from django.urls import translate_url
from django.utils.translation import activate

url = '/en/'

# Translating english url with german language activated fails
activate('de')
print(translate_url(url, 'de')) # '/en/'

# Works just fine with english language activated
activate('en')
print(translate_url(url, 'de')) # '/de/'
}}}

Not sure if this ticket is valid as `translate_url` is not documented by
the official docs, might be I'm using it wrongly?

--

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

Django

unread,
Nov 12, 2018, 11:30:39 AM11/12/18
to django-...@googlegroups.com
#29944: Can't translate URL if activated language is different than the URL's
-------------------------------------+-------------------------------------

Reporter: Pacu2 | Owner: nobody
Type: Bug | Status: new
Component: | Version: 2.1
Internationalization |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham):

Did you look at the code of `translate_url()` to understand how it works
and why the behavior is the way it is? "Not sure if this ticket is valid"
requests should generally be directed at our
[wiki:TicketClosingReasons/UseSupportChannels support channels].

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

Django

unread,
Nov 13, 2018, 7:03:59 PM11/13/18
to django-...@googlegroups.com
#29944: Can't translate URL if activated language is different than the URL's
-------------------------------------+-------------------------------------
Reporter: Filip Kucharczyk | Owner: nobody
Type: Bug | Status: closed
Component: | Version: 2.1
Internationalization |
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

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


Comment:

I didn't find
[https://github.com/django/django/blob/ff8020ed49571b0fece67d10d7398d5f57cbaa74/tests/i18n/patterns/tests.py#L153-L164
any tests] for the use case you mentioned, so I guess that's not what it's
designed to do.

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

Reply all
Reply to author
Forward
0 new messages