Displaying data {category.name}

2 views
Skip to first unread message

Jeff D

unread,
Jun 7, 2008, 12:44:30 AM6/7/08
to django-multilingual
Hi,

I'm having fun working with djano-multilingual and especially like the
idea that if you call set_default_language('fr') that is will make
{category.name} the same as {catetory.name_fr} in the templates.

However I was wondering if instead of having to call
set_default_language(), could we look for the language preference in
the session/cookie (similarly to how i18n works in the django core) or
is there a design/technical reason why this isn't good.

If adding this is ok, I'd be happy to do it and submit it for
inclusion back into the trunk if I could get a little guidance to
where in the code it should be done.

Thanks,
Jeff

Joost Cassee

unread,
Jun 7, 2008, 4:28:55 AM6/7/08
to django-mu...@googlegroups.com
On 07-06-08 06:44, Jeff D wrote:

> I'm having fun working with djano-multilingual and especially like the
> idea that if you call set_default_language('fr') that is will make
> {category.name} the same as {catetory.name_fr} in the templates.
>
> However I was wondering if instead of having to call
> set_default_language(), could we look for the language preference in
> the session/cookie (similarly to how i18n works in the django core) or
> is there a design/technical reason why this isn't good.

Mercin (the project lead) mentioned somewhere that he felt there are
situations where you would not want to set_default_language. Still, he
welcomed suggestions for an easy way of doing so automatically.

See:
http://code.google.com/p/django-multilingual/issues/detail?id=20
http://groups.google.com/group/django-multilingual/browse_thread/thread/6801ea196d2aa2a9/1c8c854c474cb420
http://groups.google.com/group/django-multilingual/browse_thread/thread/b05fc30232069e1d/3e2e3ef2830cc36a
http://groups.google.com/group/django-multilingual/browse_thread/thread/551bf9b24c2bd644/4f2f7b9c55ad0b08

Regards,

Joost

Jeff D

unread,
Jun 10, 2008, 1:21:11 PM6/10/08
to django-multilingual
Thanks Joost,

I read through the posts, dwelled on it for a bit and it makes sense.
Thanks for the reply :)

-Jeff



On Jun 7, 1:28 pm, Joost Cassee <cas...@gmail.com> wrote:
> On 07-06-08 06:44, Jeff D wrote:
>
> > I'm having fun working with djano-multilingual and especially like the
> > idea that if you call set_default_language('fr') that is will make
> > {category.name} the same as {catetory.name_fr} in the templates.
>
> > However I was wondering if instead of having to call
> > set_default_language(), could we look for the language preference in
> > the session/cookie (similarly to how i18n works in the django core) or
> > is there a design/technical reason why this isn't good.
>
> Mercin (the project lead) mentioned somewhere that he felt there are
> situations where you would not want to set_default_language. Still, he
> welcomed suggestions for an easy way of doing so automatically.
>
> See:http://code.google.com/p/django-multilingual/issues/detail?id=20http://groups.google.com/group/django-multilingual/browse_thread/thre...http://groups.google.com/group/django-multilingual/browse_thread/thre...http://groups.google.com/group/django-multilingual/browse_thread/thre...
>
> Regards,
>
> Joost

Joost Cassee

unread,
Jun 10, 2008, 1:32:43 PM6/10/08
to django-mu...@googlegroups.com
On 10-06-08 19:21, Jeff D wrote:
> On Jun 7, 1:28 pm, Joost Cassee <cas...@gmail.com> wrote:
>> On 07-06-08 06:44, Jeff D wrote:
>>
>>> I'm having fun working with djano-multilingual and especially like the
>>> idea that if you call set_default_language('fr') that is will make
>>> {category.name} the same as {catetory.name_fr} in the templates.
>>> However I was wondering if instead of having to call
>>> set_default_language(), could we look for the language preference in
>>> the session/cookie (similarly to how i18n works in the django core) or
>>> is there a design/technical reason why this isn't good.
>>
>> Mercin (the project lead) mentioned somewhere that he felt there are
>> situations where you would not want to set_default_language. Still, he
>> welcomed suggestions for an easy way of doing so automatically.
>
> I read through the posts, dwelled on it for a bit and it makes sense.

By the way, I recently added middelware to DM to automatically set the
default language. Just add
'multilingual.middleware.DefaultLanguageMiddleware' to your
MIDDLEWARE_CLASSES list. If you add it after
'django.middleware.locale.LocaleMiddleware' you get a great i18n system.


Regards,

Joost

--
Joost Cassee
http://joost.cassee.net

signature.asc

Panos Laganakos

unread,
Jun 10, 2008, 2:54:36 PM6/10/08
to django-mu...@googlegroups.com
This should probably be added to the wiki for others to take advantage of it.

--
Panos Laganakos

Joost Cassee

unread,
Jun 10, 2008, 4:06:32 PM6/10/08
to django-mu...@googlegroups.com
On 10-06-08 20:54, Panos Laganakos wrote:

> On Tue, Jun 10, 2008 at 8:32 PM, Joost Cassee <jo...@cassee.net> wrote:
>
>> By the way, I recently added middelware to DM to automatically set the
>> default language. Just add
>> 'multilingual.middleware.DefaultLanguageMiddleware' to your
>> MIDDLEWARE_CLASSES list. If you add it after
>> 'django.middleware.locale.LocaleMiddleware' you get a great i18n system.
>

> This should probably be added to the wiki for others to take advantage of it.

Good point, added.

signature.asc
Reply all
Reply to author
Forward
0 new messages