Monday, August 13, 2012

Re: how to let user change the language

Hi Gelonida,

I haven't ever worked with internalization but off the top of my head
after reading the documentation, if I was faced with implementing
this, I would first add a field to the user profile say
'preferred_lang'. Next, I would write code that would first check if a
preferred language has already been set in the user's session or
browser cookie. If yes, let internalisation work as usual else, check
the 'preferred_language' from the user's profile and store it in the
session or browser cookie and let internalization work as usual.

I hope that gives you some ideas and if you like the idea and run into
problems, you would be able to get a lot of helpful answers from the
group

On 8/12/12, Gelonida N <gelonida@gmail.com> wrote:
> On 08/12/2012 08:46 PM, Marcin Tustin wrote:
>> This is linked from the Django front page:
>> https://docs.djangoproject.com/en/1.4/topics/i18n/
>>
>> Come back with specific questions when you get stuck.
>
>
> Thanks for your answer.
>
> I created already all the l18n messages and I can switch the language
> site wise by changing the language in settings.py
>
> However Now I'd like to change them via user preferences. (not cookies)
> (So if one user changes the language on one m,achine it should be
> changed on any other machine if he logs in.
>
> I'd prefer not to set the language as suggested by the browser, but let
> the user the choice even if his useragent suggests another prefered
> language.
>
>
> There seems to be a url based approach and a cookies based approach I
> wonder what would be best for my scenario.
> (I am in full control of the web server and can add redirects / rewrite
> rules, etc. if this helps)
>
>
> This might be explained somewhere in more details in the Django docss
> however I did not find the related page.
>
> The doc mentions:
> "It uses these hooks to localize Web apps for particular users according
> to their preferences."
>
> but I did not find the how
>
>
>>
>> On Sun, Aug 12, 2012 at 1:10 PM, Gelonida N <gelonida@gmail.com
>> <mailto:gelonida@gmail.com>> wrote:
>>
>>
>> I'd like to have a web site, where the can switch the language
>> The first time the user connects the language would be the prefered
>> language as sugegsted by the news agent,
>> then the user could select the prefered lanngauge in some user
>> preference settings.
>>
>>
>>
>> What would be the standard way to do this in Django?
>>
>> Thanks in advance for comments, examples, snippets, links,
>>
>> --
>> 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
>> <mailto:django-users@googlegroups.com>.
>> To unsubscribe from this group, send email to
>> django-users+unsubscribe@__googlegroups.com
>> <mailto:django-users%2Bunsubscribe@googlegroups.com>.
>> For more options, visit this group at
>> http://groups.google.com/__group/django-users?hl=en
>> <http://groups.google.com/group/django-users?hl=en>.
>>
>>
>>
>>
>> --
>> Marcin Tustin
>> Tel: 07773 787 105
>>
>> --
>> 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
>> django-users+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>
>
> --
> 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
> django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

--
Sent from my mobile device

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate