开发者

Django Localization: How to do functional test?

开发者 https://www.devze.com 2023-02-05 08:20 出处:网络
I\'ve localized my site following the documentation. Now, I\'ve wanted to test this through the browser. But, I seem not to be able to figure out how this is done.

I've localized my site following the documentation.

Now, I've wanted to test this through the browser. But, I seem not to be able to figure out how this is done.

I am using FF and in preference / content / languages, added 'es'. I also moved it to the top of the languages 开发者_开发百科list.

Then when I go to the site, I don't see anything translated.

What am I missing?

Thanks Eric


Django stores the language code in the cookie for each user. You'll probably want to make use of Django's set_language view, perhaps at least in your development environment, because it's quicker than deleting cookie entries or destroying sessions. I used it to write a custom view that switches between the base language and another one to snoop through the site just to be 100% sure I'm translating everything.

If that still doesn't work, might want to make sure you've added it to the list of LANGUAGES and that you've added the django.middleware.locale.LocaleMiddleware to your list of middleware, because it's responsible for parsing Accept-Language from request headers.

0

精彩评论

暂无评论...
验证码 换一张
取 消