#36279: translatable path without a name attribute does not translate in
django.urls.base.translate_url
-------------------------------------+-------------------------------------
Reporter: Rami | Owner: (none)
Type: Bug | Status: new
Component: Core (URLs) | Version: 5.1
Severity: Normal | Resolution:
Keywords: set_language, i18n, | Triage Stage: Accepted
translate_url, url, translation, |
url path |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):
* easy: 1 => 0
* stage: Unreviewed => Accepted
* summary: Maybe a little Bug in `django.urls.base.translate_url` =>
translatable path without a name attribute does not translate in
django.urls.base.translate_url
Comment:
Thank you, replicated
{{{#!diff
--- a/tests/i18n/patterns/tests.py
+++ b/tests/i18n/patterns/tests.py
@@ -186,6 +186,10 @@ class URLTranslationTests(URLTestCaseBase):
translate_url("/en/account/register-as-path/", "nl"),
"/nl/profiel/registreren-als-pad/",
)
+ self.assertEqual(
+ translate_url("/en/register-as-path/", "nl"),
+ "/nl/registreren-als-pad/",
+ )
self.assertEqual(translation.get_language(), "en")
# re_path() URL with parameters.
self.assertEqual(
diff --git a/tests/i18n/patterns/urls/default.py
b/tests/i18n/patterns/urls/default.py
index 090b92eeca..0563394013 100644
--- a/tests/i18n/patterns/urls/default.py
+++ b/tests/i18n/patterns/urls/default.py
@@ -35,4 +35,5 @@ urlpatterns += i18n_patterns(
re_path(
_(r"^account/"), include("i18n.patterns.urls.namespace",
namespace="account")
),
+ path(_("register-as-path/"), view),
)
}}}
--
Ticket URL: <
https://code.djangoproject.com/ticket/36279#comment:2>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.