首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >您没有为...指定i18n转换域...在Plone中的[genericsetupprofile注册]中

您没有为...指定i18n转换域...在Plone中的[genericsetupprofile注册]中
EN

Stack Overflow用户
提问于 2012-09-21 02:02:41
回答 1查看 396关注 0票数 4

在Plone启动时,我从一个定制产品中得到了警告

代码语言:javascript
复制
/Users/mikko/code/buildout-cache/eggs/zope.configuration-3.7.4-py2.7.egg/zope/configuration/fields.py:416:
UserWarning: You did not specify an i18n translation domain for the 'title' field in /Users/mikko/code/xxx-dev/src/xxx-eggs/Products.xxxExternal/Products/xxxExternal/configure.zcml

但是,在configure.zcml中有i18:domain集。我还用一些额外的属性直接设置它,只是为了确保:

代码语言:javascript
复制
<configure  xmlns="http://namespaces.zope.org/zope"
    xmlns:five="http://namespaces.zope.org/five"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    xmlns:browser="http://namespaces.zope.org/browser"
    xmlns:i18n="http://namespaces.zope.org/i18n"
    i18n:domain="xxxPatient"
    >

  <include package=".browser" />
  <include package="plone.app.z3cform" />

    <!-- Register the installation GenericSetup extension profile -->
    <genericsetup:registerProfile
      name="default"
      title="xxxExternal"
      directory="profiles/default"
      provides="Products.GenericSetup.interfaces.EXTENSION"
      i18n:attributes="title; description"
      i18n:domain="xxxPatient"
      />


</configure>

这是给出警告的相关代码:

代码语言:javascript
复制
def fromUnicode(self, u):
    context = self.context
    domain = getattr(context, 'i18n_domain', '')
    if not domain:
        domain = 'untranslated'
        import pdb ; pdb.set_trace()
        warnings.warn(
            "You did not specify an i18n translation domain for the "\
            "'%s' field in %s" % (self.getName(), context.info.file )
            )
    v = super(MessageID, self).fromUnicode(u)

你知道为什么i18n:domain没有出现,或者如何摆脱警告吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-09-21 03:50:12

请注意,代码查找的是带下划线的i18n_domain,但是您将其指定为i18n:domain,这是一个名称空间值。

以下是工作原理:

代码语言:javascript
复制
<configure  xmlns="http://namespaces.zope.org/zope"
    xmlns:five="http://namespaces.zope.org/five"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    xmlns:browser="http://namespaces.zope.org/browser"
    i18n_domain="xxxPatient"
    >

  <include package=".browser" />
  <include package="plone.app.z3cform" />

    <!-- Register the installation GenericSetup extension profile -->
    <genericsetup:registerProfile
      name="default"
      title="xxxExternal"
      directory="profiles/default"
      provides="Products.GenericSetup.interfaces.EXTENSION"
      />

</configure>

当涉及到国际化时,ZCML与ZPT是不同的。:-)

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12518245

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档