문제

I want to set up a very small site in three different languages.

Basically I want to use a single view that sends back different data to the same template dependent on the selected language (all data is in one table anyway).

I just read through the internationalization documentation which gives a good overview but I still don't really get how to render the right kind of content based on a selected language. It seems as if I can extract this information with the requestcontext class but how exactly? Or am I over complicating things? Can somebody provide a good example?

도움이 되었습니까?

해결책

This should do the trick

from django.utils import translation
language= translation.get_language_from_request(request)
translation.activate(language)

And maybe this answer could help you, too.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top