【问题标题】:django-oscar categories and products translationsdjango-oscar 类别和产品翻译
【发布时间】:2017-02-22 18:44:17
【问题描述】:

我想使用django-oscar 建立一个网上商店,这个商店将提供两种主要语言。

Oscar's 翻译对View chartAdd to chart 等常规字段非常有效,但不支持自定义元素,例如CategoriesProduct's Titles.

我想翻译:

  • Category
  • Product.Title
  • Product.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


【解决方案1】:

使用django-modeltranslation 是个好主意。

即使根据customization instructions 来自oscar's docs 和ModelForm description 来自modeltranslation's docs 更新仪表板也做得很好。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-05-11
  • 2015-02-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-12
相关资源
最近更新 更多