开发者

Django internationalization for beginners

开发者 https://www.devze.com 2023-01-03 23:49 出处:网络
How to turn it on? According to this http://docs.djangoproject.com/en/1.2/topics/i18n/internationalization/

How to turn it on?

According to this http://docs.djangoproject.com/en/1.2/topics/i18n/internationalization/

I put into my template /var/www/project/template/index.html

{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
<html><body><h1>{% trans "It works!" $}</h1>
get_current_language = {{ LANGUAGE_CODE }}<br>
get_available_lang开发者_Python百科uages = {{ LANGUAGES}}<br></body></html>

and in folder /var/www/project/template/ I create locale subfolder than I run

django-admin makemessages -l pl_pl

processing language pl_pl

and there's no files in locale/pl_pl/LC_MESSAGES/ (which are automagicaly created)

What should I do more?


Shouldn't your index file be in project/templates/ (with an s) ? Otherwise, have you declared 'project' in your INSTALLED_APPS ?


DAMNED. I haven't noticed this:

<html><body><h1>{% trans "It works!" $}</h1>

___________________________________________________________________ ^

Now it works.. I mean - it creates django.po and django.mo. But I still see It works - not translated strings. I even creates locales/en and locales/en_us with some different strings - still I see It works.

SOLVED I have to put /var/www/project/templates/app/locale into settings.py to variable LOCALE_PATHS

Not intuitive.

0

精彩评论

暂无评论...
验证码 换一张
取 消