i18n消息:来自多个PO文件的消息的优先级

时间:2015-05-06 12:59:23

标签: internationalization plone zope buildout

我创建了一个schemaextender包,其中我试图覆盖bikaplone域的某些字符串。我的新软件包的来源是:https://github.com/rockfruit/bika.uw.git

我推荐和使用的安装方法(对于所有plone插件/实例)是:

  • 安装Plone的UnifiedInstaller。
  • 修改'eggs ='和'develop ='行,包括“bika.lims”和“bika.uw”。
  • 运行bin / buildout

使用此安装方法,我的覆盖不会覆盖。在zope.i18n中,我看到translationdomain.py总是更喜欢原始翻译,并且只在原始bika目录中没有相同字符串时才使用schemaextender包中的那些(即,对于在Python或TAL中翻译的消息)扩展包本身的代码;在所有Bika或Plone代码中,我的新目录都被忽略了。)

我已经读过buildout.cfg中的zcml =部分可能用于强制更改zcml加载顺序,导致从早期加载的包中首选消息。所以我尝试修改如下,但bika.lims的目录仍然是首选:

zcml =
    Products.CMFPlone
    bika.uw
    bika.lims

现在,这是我找到的线索。我上面链接的github存储库在root上有一个buildout.cfg,它不使用UnifiedInstaller,而是直接下载Plone和其他依赖项。它不包含zcml = line。但令人惊讶的是(对我而言)使用这种安装方法时两个域的翻译覆盖(就像买了一个!):

git clone https://github.com/rockfruit/bika.uw.git
cd bika.uw
virtualenv .
./bin/pip install zc.buildout
bin/buildout
bin/zeoserver fg &  # no idea why 'start' does not work
bin/zeoclient fg

我的问题是:我做错了什么,正常和推荐的安装程序会阻止我的翻译覆盖使用其正确的优先权?

我很尴尬地承认,但无论如何我会这样做:这让我感到困惑

我已经粘贴了下面的现有buildout.cfg,今天早上我试图模仿bika.uw.git / buildout.cfg文件的行为,但没有成功。

[buildout]

# buildout-original.cfg is the Plone 4.3.4 zeocluster unified-installer file.
extends =
    buildout-original.cfg

zeo-address = 8081
client1-address = 8085
client2-address = 8086

effective-user = campbell
buildout-user = campbell
user=admin:adminsecret

need-sudo = no
var-dir=${buildout:directory}/var
backups-dir=${buildout:directory}/backups
deprecation-warnings = on
verbose-security = on

eggs =
    bika.uw
    bika.lims
    pudb
    i18ndude
    test
    robot
    zest.releaser

develop +=
    /home/campbell/Plone/repos/bika.uw
    /home/campbell/Plone/repos/bika.lims

parts =
    zeoserver
    client1
    client2
    backup
    zopepy
    unifiedinstaller

zcml =

[zeoserver]
<= zeoserver_base
recipe = plone.recipe.zeoserver
zeo-address = 127.0.0.1:${buildout:zeo-address}
zserver-threads = 1

[client1]
<= client_base
recipe = plone.recipe.zope2instance
zeo-address = ${zeoserver:zeo-address}
http-address = ${buildout:client1-address}
resources = ${buildout:directory}/resources
locales = ${buildout:directory}/locales

[client2]
<= client_base
recipe = plone.recipe.zope2instance
zeo-address = ${zeoserver:zeo-address}
http-address = ${buildout:client2-address}
resources = ${buildout:directory}/resources
locales = ${buildout:directory}/locales

[versions]
Cheetah = 2.2.1
plone.recipe.command = 1.1
plone.recipe.precompiler = 0.6
plone.recipe.unifiedinstaller = 4.3.1
Products.DocFinderTab = 1.0.5
ZopeSkel = 2.21.2
collective.recipe.backup = 2.14
zopeskel.dexterity = 1.5.3
zopeskekel.dexterity = 1.5.3
zopeskel.diazotheme = 1.1

1 个答案:

答案 0 :(得分:0)

我认为我在2012年的Arnhem Plone会议上为talk提供的清单仍然准确无误。这是加载po文件的顺序:

  1. locales = $ {buildout:directory} / locales
  2. zcml = your.package
  3. 产品按字母顺序排列,包括Products.CMFPlone
  4. 使用z3c.autoinclude
  5. 注册的软件包
  6. 其他产品
  7. i18n文件夹(由PlacelessTranslationService完成)
  8. 在您的情况下:从zcml参数中删除Products.CMFPlone。它混合了订单。