Add info about how django chooses which language to use

This commit is contained in:
Craig Blaszczyk 2014-12-26 12:52:17 +00:00
parent 7ad7dd6a42
commit 2781903a5a

View File

@ -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 users 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