Using multilingual and localeurl in django
Posted
by Dmitry A. Erokhin
on Stack Overflow
See other posts from Stack Overflow
or by Dmitry A. Erokhin
Published on 2010-02-16T20:10:45Z
Indexed on
2010/04/19
11:33 UTC
Read the original article
Hit count: 446
Using dajngo-multilingual and localeurl.
Small sample of my main page view:
def main(request): #View for http://www.mysite.com/
name = Dog.objects.all()[0].full_name #this is a translated field
return render_to_response("home.html", {"name" : name})
Entering http://www.mysite.com/ redirects me to http://www.mysite.com/ru/ and "name" variable gets russian localization. For now it's ok...
But...
Entering http://www.mysite.com/en/ shows me same russian loclized variable.
During my experiments with debuger I've discovered:
- request.LANGUAGE_CODE is changing properly according to /en/ or /ru/ url suffix (thanx to localeurl)
- invoking multilingual.languages.set_default_language() makes "name" variable change loclization
The question is: should I change language of django-multilingual to request.LANGUAGE_CODE in each of my view myself, or it must be solved automaticly and I've done something wrong?
© Stack Overflow or respective owner