On Wed, 2008-07-16 at 10:27 -0700, Valery wrote: > Hi all, > > I would like to force a translation language according to URI- > parameter. Something similar is done here: > http://www.jondesign.net/articles/2006/jul/02/langue-depuis-url-django-url-locale-middleware/#thecode > > but it is done there on the middleware level. In my case a decision > about language should be taken inside of a regular view function. My > view function is very simple: > > def myview(request,lng, myval): > return render_to_response('mytemplate.html', { 'myvar' : myval}) > > How could it be done (if at all) ?
It's not documented in the i18n.txt file (which needs a bit of a rewrite and splitting up once the docs reorganisation lands in trunk), but have a look at the activate() function in django/utils/translation/trans_real.py. Basically, activate('de') for example, will switch the currently active locale to be "de". That's how the middleware sets the active locale in the first place. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---