summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorKrzysztof Urbaniak <urban@fail.pl>2016-02-29 09:24:19 +0100
committerTim Graham <timograham@gmail.com>2016-03-08 08:14:10 -0500
commit839a955d08fa0657622ed9b60fdd262658fa659f (patch)
treeeb671debf7695b40d27da97946ab0d9479d68566 /docs
parent4b129ac81f4fa38004950d0b307f81d1e9b44af8 (diff)
Fixed #25933 -- Allowed an unprefixed default language in i18n_patterns().
Diffstat (limited to 'docs')
-rw-r--r--docs/releases/1.10.txt4
-rw-r--r--docs/topics/i18n/translation.txt25
2 files changed, 27 insertions, 2 deletions
diff --git a/docs/releases/1.10.txt b/docs/releases/1.10.txt
index e19ecf5662..4f10dc1cd9 100644
--- a/docs/releases/1.10.txt
+++ b/docs/releases/1.10.txt
@@ -248,6 +248,10 @@ Internationalization
used in a root URLConf specified using :attr:`request.urlconf
<django.http.HttpRequest.urlconf>`.
+* By setting the new ``prefix_default_language`` parameter for
+ :func:`~django.conf.urls.i18n.i18n_patterns` to ``False``, you can allow
+ accessing the default language without a URL prefix.
+
Management Commands
~~~~~~~~~~~~~~~~~~~
diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt
index 86778859e9..7be20f6d23 100644
--- a/docs/topics/i18n/translation.txt
+++ b/docs/topics/i18n/translation.txt
@@ -1326,11 +1326,17 @@ Django provides two mechanisms to internationalize URL patterns:
Language prefix in URL patterns
-------------------------------
-.. function:: i18n_patterns(*pattern_list)
+.. function:: i18n_patterns(*urls, prefix_default_language=True)
This function can be used in a root URLconf and Django will automatically
prepend the current active language code to all url patterns defined within
-:func:`~django.conf.urls.i18n.i18n_patterns`. Example URL patterns::
+:func:`~django.conf.urls.i18n.i18n_patterns`.
+
+Setting ``prefix_default_language`` to ``False`` removes the prefix from the
+default language (:setting:`LANGUAGE_CODE`). This can be useful when adding
+translations to existing site so that the current URLs won't change.
+
+Example URL patterns::
from django.conf.urls import include, url
from django.conf.urls.i18n import i18n_patterns
@@ -1371,6 +1377,21 @@ function. Example::
>>> reverse('news:detail', kwargs={'slug': 'news-slug'})
'/nl/news/news-slug/'
+With ``prefix_default_language=False`` and ``LANGUAGE_CODE='en'``, the URLs
+will be::
+
+ >>> activate('en')
+ >>> reverse('news:index')
+ '/news/'
+
+ >>> activate('nl')
+ >>> reverse('news:index')
+ '/nl/news/'
+
+.. versionadded:: 1.10
+
+ The ``prefix_default_language`` parameter was added.
+
.. warning::
:func:`~django.conf.urls.i18n.i18n_patterns` is only allowed in a root