为i18ndude提供辅助/包装脚本,以便在常见的Plone环境中更容易地处理翻译文件。
项目描述
简介
将翻译添加到Plone产品的任务几乎是相同的
创建和注册本地化目录
添加语言
使用rebuild-pot命令调用i18ndude
使用sync命令调用i18ndude
多次组合运行最后两个命令与find-untranslated
并可能直接编译mo文件
zettwerk.i18nduder试图通过封装i18ndude命令,并从您的buildout主目录直接调用以避免文件夹和路径处理,使这一过程变得更简单。它并没有什么您不能直接使用i18ndude做的,但根据我们的内部使用,它使处理翻译变得更容易和更快。
为了使此功能正常工作,仅有一个假设,这在由paster创建的Plone产品中应该是常见的:您的翻译域与您的Python包同名。
安装
将i18nduder部分添加到您的buildout.cfg中,并定义如下
[i18nduder] recipe = zc.recipe.egg eggs = ${instance:eggs} zettwerk.i18nduder
包括您的实例鸡蛋非常重要,因为duder通过导入它来获取包的路径。另外请注意,zettwerk.i18nduder包含对i18ndude的依赖。
可用命令及其用法
生成的脚本称为duder。要查看命令列表,请使用–help参数。
> ./bin/duder --help > Usage: duder command -p package.name or --help for details > > Available commands: > create Create the locales folder and/or add given languages > update Call rebuild-pot and sync > mo Call msgfmt to build the mo files > find Find untranslated strings (domain independent) > > Options: > -h, --help show this help message and exit > -p PACKAGE, --package=PACKAGE > Name of the package > -d DOMAIN, --domain=DOMAIN > Name of the i18n domain. Only needed if it is different > from the package name. > -l LANGUAGES, --languages=LANGUAGES > List of comma-separated names of language strings. > Only used for create command. For example: -l en,de
示例
以下命令用于针对新建的、已在您的buildout原型产品中注册且包名为dummy.example的产品。
首先,我们创建本地化文件夹并添加一些语言
> ./bin/duder create -p dummy.example -l en,de > Created locales folder at: /home/joerg/Instances/Plone4/src/dummy.example/dummy/example/locales > Don't forget to add this to your configure.zcml: > <i18n:registerTranslations directory="locales" / > > - en language added > - de language added
要添加另一种语言,只需再次调用它即可
> ./bin/duder create -p dummy.example -l nl > Locales folder already exists at: /home/joerg/Instances/Plone4/src/dummy.example/dummy/example/locales > - nl language added
在处理dummy.example之后,必须进行一些翻译
> ./bin/duder update -p dummy.example > nl/LC_MESSAGES/dummy.example.po: 1 added, 0 removed > en/LC_MESSAGES/dummy.example.po: 1 added, 0 removed > de/LC_MESSAGES/dummy.example.po: 1 added, 0 removed
请注意,此过程不会操纵pot/po头。这必须手动完成。
还可以使用未翻译查找
> ./bin/duder find -p dummy.example > wrote output to: /home/joerg/Instances/Plone4/dummy.example-untranslated
mo文件可以像这样编译
> ./bin/duder mo -p dummy.example
这调用“msgfmt”,所以它必须存在于您的系统上。
关于域的说明
可能需要知道,i18ndude不能通过MessageFactory区分域。因此,如果使用带有域选项的duder,将得到给定域(当在模板文件中明确使用i18n:domain时)的msgids以及通过默认域的MessageFactory创建的翻译。
请随时联系我们提出建议和改进意见。
变更日志
0.2.1 (2011-04-05)
在更新调用后添加了完整路径输出
0.2 (2011-04-03)
添加了-d选项以添加显式域名
重构了命令
pep8清理
0.1 (2010-11-13)
首次发布,包括命令:创建、更新、查找、mo
项目详情
zettwerk.i18nduder-0.2.1.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 14f147d88fb1acffbbe61b45d3af4c5ed858474e723cc64f931e6a096b805abd |
|
MD5 | 5e3d0fa8e46270f83925b3d2d7fa1761 |
|
BLAKE2b-256 | 6a5c49c54ce4a429075bb90c59a2216ae760510dbfcf05f52dccf9cd7c094ced |