From 2781903a5a0be7f5314de54ff2dbc8ef393eab0a Mon Sep 17 00:00:00 2001 From: Craig Blaszczyk Date: Fri, 26 Dec 2014 12:52:17 +0000 Subject: [PATCH] Add info about how django chooses which language to use --- docs/topics/internationalisation.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/topics/internationalisation.md b/docs/topics/internationalisation.md index 552fdd273..a0aab7533 100644 --- a/docs/topics/internationalisation.md +++ b/docs/topics/internationalisation.md @@ -40,4 +40,22 @@ This guide assumes you are already familiar with how to translate a Django app. 6. Restart your server + +## How Django chooses which language to use +REST framework will use the same preferences to select which language to display as Django does. You can find more info in the [django docs on discovering language preferences][django-language-preference]. For reference, these are + +1. First, it looks for the language prefix in the requested URL +2. Failing that, it looks for the `LANGUAGE_SESSION_KEY` key in the current user’s session. +3. Failing that, it looks for a cookie +4. Failing that, it looks at the `Accept-Language` HTTP header. +5. Failing that, it uses the global `LANGUAGE_CODE` setting. + +--- + +**Note:** You'll need to include the `django.middleware.locale.LocaleMiddleware` to enable any of the per-request language preferences. + +--- + + [django-translation]: https://docs.djangoproject.com/en/1.7/topics/i18n/translation +[django-language-preference]: https://docs.djangoproject.com/en/1.7/topics/i18n/translation/#how-django-discovers-language-preference