0

Here is my settings

LANGUAGES = (
    ('zh_CN', u'简体中文'),
    ('en-us', u'English'),
)
LANGUAGE_CODE = 'en-us'

USE_I18N = True

USE_L10N = True

MIDDLEWARE_CLASSES = (

    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # "django.middleware.cache.CacheMiddleware",
    "django.middleware.transaction.TransactionMiddleware",

)

Here is some print

('django_language', '')
('COOKIES', '')
('ACCEPT_LANGUAGE', 'zh_CN')
('LANGUAGE_CODE', 'en-us')

My django version is 1.5.4

If i set

request.session['django_language'] = 'zh_CN'

I will get translation next time. What's wrong ?

Aneesh R S
  • 3,807
  • 4
  • 23
  • 35
  • What is FULL URL? Did you pass language prefix in URL? – Kaushal Aug 15 '17 at 07:50
  • @Kaushal no.FULL URL is {{HOST}}/api/calendarevent/eventtype/. but according to the document. i can use accecpt-language without set language prefix? right? – 月牙天冲 Aug 15 '17 at 08:20
  • Right You can use without url prefix. But I thought may be url prefix conflict with accept header. Did you used `django rest`? which version of `django-rest` ? if `< 3.00`did you check if `2.XX` support Internationalization – Kaushal Aug 15 '17 at 08:50
  • @Kaushal I use rest 2.4.5 – 月牙天冲 Aug 15 '17 at 12:16
  • internationalization support added in rest framework from `rest framework 3.1` http://www.django-rest-framework.org/topics/3.1-announcement/ So I think you can not use directly – Kaushal Aug 15 '17 at 12:27
  • also `zh-cn` is correct config name not `zh_CN' for django version before 1.7. – Kaushal Aug 15 '17 at 12:48

0 Answers0