我试图在django制作多语言网站,但我没有对网页内容进行任何更改。
我正在研究django1.5,我在下面这样做,
setting.py
LANGUAGE_CODE = 'fr-CA'
ugettext = lambda s: s
LANGUAGES = (
('fr-CA', ugettext('French')),
('en-US', ugettext('English')),
)
LOCALE_PATHS = (
os.path.join(os.path.dirname(__file__),'locale').replace('\\','/') # zankar added
)
USE_I18N = True
django.po
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-07-09 16:05+0530\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: settings.py:45
msgid "French"
msgstr "French"
#: settings.py:46
msgid "English"
msgstr "English"
#: templates/index.html:7
msgid "Hello Zankar"
msgstr "Bonjour Zankar"
我的语言环境文件夹位于myapp之外。
我也编译了我的.po文件并创建了.mo文件。 我在创建.mo文件消息时注意到的一件事是红色。
的index.html
<html>
<head>
<title>Multi Language Test</title>
</head>
<body>
{% load i18n %}
<p>{% trans "Hello Zankar" %}</p>
</body>
</html>
请告诉我我错过了什么 我想这段代码会用法语向我展示你好的消息,但没有任何改变。 我不知道我是错了还是剧本错了,因为我是django的新人。
请帮帮我。