How do you get the preferred language?

In the 1.5 docs it says to add 'django.core.context_processors.i18n' to 
your TEMPLATE_CONTEXT_PROCESSORS which variable is that in your settings.py?

If I add it to TEMPLATE_LOADERS and refresh the page I get the error:

'function' object has no attribute 'is_usable'

/usr/local/lib/python2.7/dist-packages/django/template/loader.py in 
find_template_loader, line 112



On Monday, 22 April 2013 11:36:34 UTC-4, ayeowch wrote:
>
> There are several ways to switch language (
> https://docs.djangoproject.com/en/1.4/topics/i18n/translation/#how-django-discovers-language-preference).
>  
> I normally set django_language session variable to the preferred language.
> For 1), have you compiled your messages into .mo files? You will also need 
> to reload your server to load the new .mo files.
>
>
> On Tue, Apr 23, 2013 at 1:24 AM, Cody Scott <cody.j....@gmail.com<javascript:>
> > wrote:
>
>> I am trying to get translations to work on my site.
>>
>> I have marked words for translation and they show up in the django.po 
>> file.
>>
>> I am wondering what is the proper way to switch the current language.
>>
>> Currently I have the following in my project urls.py
>>
>> urlpatterns = i18n_patterns('',
>>     #.... etc
>> )
>>
>> urlpatterns += patterns('', 
>>     (r'^i18n/', include('django.conf.urls.i18n')),
>> )
>>
>> And to switch languages I change the /en/ in my url to /ja/ or /fr/.
>>
>> I have two issues. 
>>
>> 1) The page is not being translated except for 'Yes' and 'No' which are 
>> translated even if I remove them from my .po file. So there must be a 
>> default set of translation words? Or Chrome is seeing the /fr/ in the URL 
>> and translating it for me? I can't explain why that is happening. Even if I 
>> change what 'Yes' and 'No' translate to it doesn't change what is displayed.
>>
>> 2) The next page I visit reverts to a English with the /en/. Yes english 
>> is my default language in settings.py.
>>
>> #settings.py
>> #Used for translations
>> gettext = lambda s: s
>> LANGUAGES = (
>>     ('en', gettext('English')),
>>     ('fr', gettext('French')),
>>     ('ja', gettext('Japanese')),
>> )
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com <javascript:>.
>> To post to this group, send email to django...@googlegroups.com<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to