Hello, all.  Forgive me as I'm still fairly new to django, but I'm
having some issues getting i18n running, and I can't seem to find any
help in the online docs.

I've read chapter 18 (i18n) of djangobook.com, and chapter 10 relating
to RequestContext.  I've also read the docs on djangoproject.com for
the same subjects.

Basic problem description:  No matter what language I select, I get
English output.

My setup:
  OSX.5.3
  manually compiled gettext from source because xgettext was missing
from OSX.
  django from svn revision 7565 (did an update this morning).
  brand new project just for testing this functionality.
  mysql database (ran manage.py syncdb after getting the middle ware
setup).

What I've written:
  url r'^i18n/$' mapped to:  include('django.conf.urls.i18n') per
djangobook.com and djangoproject.com
  url r'^lang/' mapped to dolang from my views, which displays the
example code from djangobook.com on how to switch languages.  Changed
method="get" to POST so that it'll actually work.
  url r'^$' to hello_world from my views, which displays a template
say_hello.html with a simple string as output and a link to /lang/.

Hurtles I've already crossed:
  Made sure to use RequestContext in every (or both, whatever :)
request.
  Used make-message.py -l sp to generate the Spanish language files.
  Translated the two tokens (views.py:10, and templates/say_hello.html:
7) in the locale/sp/LC_MESSAGES_django.po file.
  Used compile-messages.py to compile the language into the django.mo
file.
  Ensured that the cookie is being set in my browser for the session,
and that the language is being saved to the session.
  Ensured that the language is in fact being saved to
request.LANGUAGE_CODE.
  Tried simply printing the string and bypassing the templates all
together.  Always outputs English.
  Pounded head into wall multiple times.

Any help is greatly appreciated.  I'm really excited about pitching
django to upper management and ridding myself of the perl hell I've
been tossed into.  ^_^

Below is the code, I'll leave out obvious things like import
statements.

-- views.py --
def dolang(request):
    return render_to_response('dolang.html', {},
context_instance=RequestContext(request))

def hello_world(request):
    string = _("Hello %(lang)s world!") % {'lang':
request.LANGUAGE_CODE}
    print request.session['django_language']
    print string
    return render_to_response('say_hello.html', {'string': string},
context_instance=RequestContext(request))
-- / views.py --

-- urls.py --
urlpatterns = patterns('',
    (r'^i18n/', include('django.conf.urls.i18n')),
    (r'^lang/', dolang),
    (r'^$', hello_world),
)
-- / urls.py --

-- templates/say_hello.html --
{% load i18n %}
<html>
    <body>
        <p>
            {{ string }}
        </p>
        <a href="/lang/">{% trans "Choose a language" %}</a>
    </body>
</html>
-- / templates/say_hello.html --
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to