I have solved this problem myself.

I have to declare the following variable:
LANGUAGES = (
  ('de', 'German (Deutsch)'),
  ('en', 'English'),
)

And then include the middleware
"django.middleware.locale.LocaleMiddleware"



On Aug 18, 11:20 am, stanleyxu2005 <sx.a...@googlemail.com> wrote:
> Hi All,
>
> after reading the django documentation, I still have problem with
> changing a language.
> I have create two languages: en_US and de_DE
>
> If I declare LANGUAGE_CODE='de_DE' in settings.py (without the
> middleware django.middleware.locale.LocaleMiddleware), my project will
> be translated into German.
> if I declare LANGUAGE_CODE='en_EN' (or leave it undeclared), my
> project will be translated into English.
>
> Now, I try to change the language setting in index page.
> def index(request)
>   request.session['django_language') = "de_DE"
>   from django.conf import settings
>   settings.LANGUAGE_CODE = "de_DE"
>
>   C = Context()
>   C['am'] = _("AM")
>   # and so on
>   f = open('template/overview.tpl')
>   t = Template(f.read())
>   f.close()
>   return HttpResponse(t.render(C))
> # end-def
>
> However, the index page looks always in English.
>
> What is the problem? Thanks in advance ^^)
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to