1

我正在尝试在 django 中制作多语言网站,但页面内容没有任何变化。

我正在研究 django1.5,我这样做如下所示,

设置.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 文件消息时注意到的一件事是红色。

索引.html

<html>
<head>
    <title>Multi Language Test</title>
</head>
<body>
    {% load i18n %}
    <p>{% trans "Hello Zankar" %}</p>
</body>
</html>

请告诉我我缺少哪些东西我认为这段代码会用法语向我显示你好消息,但没有任何变化。我不知道是我错了还是脚本错了,因为我是 django 的新手。

请帮我。

4

0 回答 0