我正在使用 Django Rosetta v 0.7.6(与库和 Django 版本匹配以使其在网络应用程序中运行)。它从 en-us 翻译为 ar(阿拉伯语),它几乎适用于所有内容,但缺少一些字符串,我找不到错误以及为什么没有全部翻译。
这是 settings.py 文档中的语言部分和语言环境路径,以防万一需要更改(或按照应有的不同顺序):
TEMPLATE_DIRS = (os.path.join(PACKAGE_ROOT, 'templates'),os.path.join(PACKAGE_ROOT, 'templatetags')) + TEMPLATE_DIRS
LOCALE_PATHS = (os.path.join(PACKAGE_ROOT, '../locale'),)
# If the rosetta library has been installed, and add to INSTALLED_APPS
try:
import rosetta
INSTALLED_APPS += ('rosetta',)
except ImportError:
pass
ugettext = lambda s: s
LANGUAGES = (
('en-us', ugettext('English')),
('ar', ugettext('Arabic')) #Your second language
)
LANGUAGE_CODE = 'en-us' #Your default language
USE_L10N = True
.po 文档在开始时生成模糊字符串和空字符串,然后生成一些关于版本年份日期的 mambo jumbo ......然后整个列表与文档翻译的字符串和两种语言之间的关系( #: documet/translated/form.htm:1234, msgid "en-us 中的字符串" msgstr "ar 中的字符串")。
# 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 ""`
在 .po 的整个文档中,只是缺少页面中未翻译的那些,但在 en-us 中都没有提及原始字符串,所以我想这甚至没有尝试翻译它们,因为它们不在 . po文件。
下一张图片是那些行的日志,文件......未翻译。之后 django Rosetta 页面中第一个表单的代码 .htm 部分未翻译并显示在图片中。
{% extends "views/forms/base.htm" %}
{% load i18n %}
{% block form_content %}
<!-- Resource Type CRUD Form -->
<hr class="divider arches-RDM-divider">
<div id="site_ID-section">
<!-- Name CRUD Form -->
<div class="row">
<div class="col-xs-12">
<div class="padding-left-10">
<dl>
<!-- Title -->
<dt>
<h5 id="arches-names-form" class="section-headline">{% trans "National ID" %}</h5>
</dt>
<!-- Form -->
<dd>
<div class="row">
<div class="col-xs-12 hidden-xs">
<input class="form-control arches-form-input" id="resource-name" style="width: 18%;" placeholder='{% trans "National ID" %}' data-bind='value: getEditedNode("SITE_ID.E42", "value")'>
{% include 'views/components/add-item-button.htm' %}
</div>
<div class="col-xs-12 hidden-sm hidden-md hidden-lg">
<input class="form-control arches-form-input" id="resource-name" style="width: 33%;" placeholder='{% trans "National ID" %}' data-bind='value: getEditedNode("SITE_ID.E42", "value")'>
<div class="margin-top-5"></div>
>
<!-- Spacer (for xs screens) -->
<div class="margin-top-5"></div>
{% include 'views/components/add-item-button.htm' %}
</div>
</div>
</dd>
<!-- End Form -->
</dl>
</div>
</div>
</div>
<!-- End Name CRUD Form Container -->
<!-- Name Records -->
<div class="row">
<div class="col-xs-12">
<!-- -->
<div class="arches-crud-child-section">
<dl>
<dd class="arches-CRUD-child-title">
{% trans "This resource has the following ID code:" %}
</dd>
<dd class="margin-left-5" style="display: none;" data-bind="visible: true">
<div data-bind="visible: getBranchLists().length == 0" class="txt-color-blue">{% trans "No ID Defined" %}</div>
<div data-bind='foreach: getBranchLists()'>
<div class="arches-crud-record">
<a href="javascript:void(0)" class="arches-CRUD-child" title="{% trans "Delete this name" %}"><i data-bind="click: $parent.deleteItem.bind($parent)" class="arches-CRUD-delete fa fa-times-circle"></i></a>
<a href="javascript:void(0)" class="arches-CRUD-child arches-CRUD-edit" data-bind="click: $parent.editItem.bind($parent)" title="{% trans "Edit this name" %}"><span data-bind='text: nodes.get("SITE_ID.E42", "value")' style="padding-right:2px;"></span><span class="text-muted arches-crud-type-identifier"></span>
</a>
</div>
</div>
</dd>
</dl>
</div>
</div>
</div>
请在这里是翻译和原始语言时的外观,以防万一它有助于本地化错误,我已经重新启动实例和服务器,但在执行此操作后得到相同的答案: