Reputation: 39
anyone can help me , please !!!? setting.py
LANGUAGE_CODE = 'en'
# supported languages
LANGUAGES = (
('en', 'English'),
('ko', 'Korean'),
)
Upvotes: 0
Views: 2536
Reputation: 87074
@Sayse's answer is correct, however, Django does not automatically enable LocaleMiddleware
for your project.
Once enabled (add it to MIDDLEWARE_CLASSES
in settings.py) Django will perform language detection as described here, and apps such as the admin app will use the appropriate translations.
But you still need to set up everything else; you have to mark up your translatable strings in your code and/or templates, set up the message files for each language, consider whether you want internationalisation support for URLs etc.
It would be a good idea to read the translation documentation.
Upvotes: 1
Reputation: 43300
Django works it out on its own already, there isn't anything extra you need to do.
LocaleMiddleware tries to determine the user’s language preference by following this algorithm:
First, it looks for the language prefix in the requested URL. This is only performed when you are using the i18n_patterns function in your root URLconf. See Internationalization: in URL patterns for more information about the language prefix and how to internationalize URL patterns.
Failing that, it looks for the LANGUAGE_SESSION_KEY key in the current user’s session.
Failing that, it looks for a cookie.
The name of the cookie used is set by the LANGUAGE_COOKIE_NAME setting. (The default name is django_language.)
Failing that, it looks at the Accept-Language HTTP header. This header is sent by your browser and tells the server which language(s) you prefer, in order by priority. Django tries each language in the header until it finds one with available translations.
Failing that, it uses the global LANGUAGE_CODE setting.
Upvotes: 5