我有以下的设置 -
文件夹结构:
但是结果中显示的
文件夹结构:
myapp
- conf
- locale
- ru
- LC_MESSAGES
- django.mo # contains "This is the title." translation
- django.po
- templates
- index.html
setting.py
main.py
app.yaml:
...
env_variables:
DJANGO_SETTINGS_MODULE: 'settings'
handlers:
...
- url: /locale/ # do I need this?
static_dir: templates/locale
libraries:
- name: django
version: "1.5"
settings.py:
USE_I18N = True
LANGUAGES = (
('en', 'EN'),
('ru', 'RU'),
)
LANGUAGE_CODE = 'ru'
LANGUAGE_COOKIE_NAME = 'django_language'
SECRET_KEY = 'some-dummy-value'
MIDDLEWARE_CLASSES = (
'django.middleware.locale.LocaleMiddleware'
)
LOCALE_PATHS = (
'/locale',
'/templates/locale',
)
index.html:
{% load i18n %}
...
{% trans "This is the title." %}
和 main.py:
from google.appengine.ext.webapp import template
...
translation.activate('ru')
template_values = {}
file_template = template.render('templates/index.html', template_values)
self.response.out.write(file_template)
但是结果中显示的
"This is the title."
是英文。我的设置(或文件位置)有什么问题?
template_values = {}
时,这不意味着你正在使用空字典来格式化/渲染HTML页面吗?在.render
之后它的值是什么?如果你将template_values
更改为类似于template_values = {"trans":"ru"}
这样的东西会怎样? - Tadhg McDonald-Jensen{"trans":"ru"}
- 没有帮助。 - LA_