Preparing your project for internationalization
Let’s prepare your project to use different languages. You are going to create an English and a Spanish version for your shop. Edit the settings.py
file of your project and add the following LANGUAGES
setting to it. Place it next to the LANGUAGE_CODE
setting:
LANGUAGES = [
('en', 'English'),
('es', 'Spanish'),
]
The LANGUAGES
setting contains two tuples that consist of a language code and a name. Language codes can be locale-specific, such as en-us
or en-gb
, or generic, such as en
. With this setting, you specify that your application will only be available in English and Spanish. If you don’t define a custom LANGUAGES
setting, the site will be available in all the languages that Django is translated into.
Make your LANGUAGE_CODE
setting look like the following:
LANGUAGE_CODE = 'en'
Add 'django.middleware.locale.LocaleMiddleware'
to...