I just want to share the sample code. Anything wrong? File size is only 9k.
>> i18nsample.zip
>> 9KViewDownload
I use Gmail to check this group. So I could send a email to this group
with attachments.
>
> On Sep 6, 5:01 pm, A.TNG <tang.j...@gmail.com> wrote:
I find another way to use django's i18n middleware.
The story is that you already have a app based on webapp framework and
you want to make it support i18n.
1. you still need to create your .po and .mo files and put them under
appproj/locale/{locale, eg: zh_CN}/LC_MESSAGES/
2. add settings.py to appproj/
3. modify your main.py and import several django modules.
4. Now, you could use _() in .py and {% trans "" %} in template. You
could follow your webapp way, no need to change to django way.
For detail information, you could check attached code sample. Enjoy :-)
Originally in Django, locale could be set via session. But GAE cannot
work with session in Django. So I tried to set
settings.LANGUAGE_CODE='zh-cn' directly to make i18n works
dynamically. It works.
Maybe there are some other ways.
I never tried Django 1.0. All above is based on GAE built-in Django 0.96.1.
Oh, I made a mistake. I'm not familiar with Django. So, I thought it
would work at first.
Now, I have no idea how to make i18n work dynamically. If I in a pure
Django Environment, session, cookie are both used to change language.
But, How could it be done in webapp framework?
Do you have any idea? I meet some similar problems in my project too.
>
> Best Regards
> Alex