| 1 |
from django.conf.urls.i18n import i18n_patterns |
| 2 |
from django.urls import include, path, re_path |
| 3 |
from django.utils.translation import gettext_lazy as _ |
| 4 |
from django.views.generic import TemplateView |
| 5 |
|
| 6 |
view = TemplateView.as_view(template_name="dummy.html") |
| 7 |
|
| 8 |
urlpatterns = [ |
| 9 |
path("not-prefixed/", view, name="not-prefixed"), |
| 10 |
path("not-prefixed-include/", include("i18n.patterns.urls.included")), |
| 11 |
path(_("translated/"), view, name="no-prefix-translated"), |
| 12 |
re_path(_(r"^translated-regex/$"), view, name="no-prefix-translated-regex"), |
| 13 |
re_path( |
| 14 |
_(r"^translated/(?P<slug>[\w-]+)/$"), |
| 15 |
view, |
| 16 |
{"slug": "default-slug"}, |
| 17 |
name="no-prefix-translated-slug", |
| 18 |
), |
| 19 |
] |
| 20 |
|
| 21 |
urlpatterns += i18n_patterns( |
| 22 |
path("prefixed/", view, name="prefixed"), |
| 23 |
path("prefixed.xml", view, name="prefixed_xml"), |
| 24 |
re_path( |
| 25 |
_(r"^with-arguments/(?P<argument>[\w-]+)/(?:(?P<optional>[\w-]+).html)?$"), |
| 26 |
view, |
| 27 |
name="with-arguments", |
| 28 |
), |
| 29 |
path( |
| 30 |
_("path-with-arguments/<str:argument>/"), |
| 31 |
view, |
| 32 |
name="path-with-arguments", |
| 33 |
), |
| 34 |
re_path(_(r"^users/$"), view, name="users"), |
| 35 |
re_path( |
| 36 |
_(r"^account/"), include("i18n.patterns.urls.namespace", namespace="account") |
| 37 |
), |
| 38 |
) |