On Tue, 2007-07-10 at 21:14 +0300, Amit Ramon wrote:
> Hello,
> 
> I'm working on a multi-lingual site. I'm using django-multilingual for 
> translating the content and I've set up a url scheme with a language code as 
> the first part of the url (e.g.,  "/en/pages/about/"), as I'd like users to 
> explicitly select their language. 
> 
> I'm also using django's set_language redirect view to move between the 
> different language versions of the same page. This works fine.
> 
> The problem I'm facing is how to set the django's system language when 
> accessing a page via a url - by this I mean, for example, how to get string 
> translation (e.g., using the templates "trans" thing). For example, when 
> using a "/en/..." url I want to explicitly, in code, set the language to 
> English, and when using a "/he/..." url I want to be able to set the language 
> to Hebrew, and get strings translated. Unfortunately, I couldn't get this to 
> work so far. It seems django has an algorithm for selecting the language, 
> based on user's browser settings or cookies,  and I cannot force it to use 
> the language I want.

Look at django.util.translation.activate(). You pass it the language
code you want to be in effect. So just call that early enough in the
view processing and you should be fine. You could even write your own
middleware to set this automatically (base it off the LocaleMiddleware
if you want some hints).

Regards,
Malcolm

-- 
Works better when plugged in. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to