【发布时间】:2017-02-22 18:44:17
【问题描述】:
我想使用django-oscar 建立一个网上商店,这个商店将提供两种主要语言。
Oscar's 翻译对View chart 或Add to chart 等常规字段非常有效,但不支持自定义元素,例如Categories 或 Product's Titles.
我想翻译:
CategoryProduct.TitleProduct.Description
我想出了两种方法:
方法一 - 修改django-oscar模板
我可以根据oscar's translation doc创建自定义翻译集。
然后用翻译的类别和产品标题填写适当的django.po 文件。
不幸的是,我将不得不覆盖一些模板,因为默认情况下它们不使用 trans 模板标签。例如。我会改变的。
<a href="{{ category.get_absolute_url }}">{{ category.name }}</a>
到
<a href="{{ category.get_absolute_url }}">{% trans category.name %}</a>
在this oscar 的模板中。
这种方法的主要问题是需要覆盖模板、更新django.po 以及使用每个要翻译的新条目编译它。
方法二 - 使用django-modeltranslation
使用this 插件。
问题
我是否错过了django-oscar's 功能中的一些构建,或者我必须使用上述方法之一?
【问题讨论】:
-
django-modeltranslation解决了这个问题。
标签: django locale translation django-oscar django-modeltranslation