i18n: How to the language on per-user basis
Hallöchen! In my Web application, every user has to log in. In an additional user database table, the prefered language of each user is given. But how do I activate it? I use django.contrib.auth.views.login for the login. However, as far as I can see, I have to copy-and-paste this function and add a line to it which stors the language in the current session. Am I right? Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: i18n: How to the language on per-user basis
Hi, > In my Web application, every user has to log in. In an additional > user database table, the prefered language of each user is given. > But how do I activate it? > > I use django.contrib.auth.views.login for the login. However, as > far as I can see, I have to copy-and-paste this function and add a > line to it which stors the language in the current session. Am I > right? Yes, that would do it. -Rajesh D --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: i18n: How to the language on per-user basis
You could use "user profiles" which will allow you to store various user specific preferences. See [1] to learn how to do this. I am currently using profiles to identify users by the department they work in and the last time they edited a form (this is different from last login). Best, R [1] - http://www.djangoproject.com/documentation/authentication/#storing-additional-information-about-users On Thu, Jul 17, 2008 at 6:32 PM, Torsten Bronger < [EMAIL PROTECTED]> wrote: > > Hallöchen! > > In my Web application, every user has to log in. In an additional > user database table, the prefered language of each user is given. > But how do I activate it? > > I use django.contrib.auth.views.login for the login. However, as > far as I can see, I have to copy-and-paste this function and add a > line to it which stors the language in the current session. Am I > right? > > Tschö, > Torsten. > > -- > Torsten Bronger, aquisgrana, europa vetus > Jabber ID: [EMAIL PROTECTED] > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: i18n: How to the language on per-user basis
Hello, Sometimes ago I try to solve a similar problem, it seems to me that the solution to your problem is to write a middleware. You will find an example there : http://yml-blog.blogspot.com/search/label/Django ---8< from django.utils.cache import patch_vary_headers from django.utils import translation class MultilingualURLMiddleware: def get_language_from_request (self,request): # This is the place where you should write # the logic to find the right language lang = user.language # <= May be something like return lang def process_request(self, request): from django.conf import settings language = self.get_language_from_request(request) if language is None: language = settings.LANGUAGE_CODE[:2] translation.activate(language) request.LANGUAGE_CODE = translation.get_language() def process_response(self, request, response): patch_vary_headers(response, ("Accept-Language",)) translation.deactivate() return response --8<-- I hope that help. --yml On Jul 18, 2:01 pm, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote: > You could use "user profiles" which will allow you to store various user > specific preferences. See [1] to learn how to do this. > > I am currently using profiles to identify users by the department they work > in and the last time they edited a form (this is different from last login). > > Best, > > R > > [1] -http://www.djangoproject.com/documentation/authentication/#storing-ad... > > On Thu, Jul 17, 2008 at 6:32 PM, Torsten Bronger < > > [EMAIL PROTECTED]> wrote: > > > Hallöchen! > > > In my Web application, every user has to log in. In an additional > > user database table, the prefered language of each user is given. > > But how do I activate it? > > > I use django.contrib.auth.views.login for the login. However, as > > far as I can see, I have to copy-and-paste this function and add a > > line to it which stors the language in the current session. Am I > > right? > > > Tschö, > > Torsten. > > > -- > > Torsten Bronger, aquisgrana, europa vetus > > Jabber ID: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: i18n: How to the language on per-user basis
Am 18.07.2008 um 14:01 schrieb Rishabh Manocha: > You could use "user profiles" which will allow you to store various > user specific preferences. At the Pinax project for example, we are using a language field in the profile model [1] together with a custom middleware [2] to set the locale of the website for every logged-in user. Cheers, Jannis 1: http://code.google.com/p/django-hotclub/source/browse/trunk/projects/pinax/profiles/models.py#18 2: http://code.google.com/p/django-hotclub/source/browse/trunk/projects/pinax/profiles/middleware.py --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---