zope.i18n.translationdomain的增强版本
sx.translations的Python项目详细描述
此包提供用于zope 3和zope 2的组件+ 五个同时实现itranslationdomain和 语言可用性以及支持 未翻译的msgid。这意味着,不仅仅是组件 支持接口需要向zope 3的i18n提供消息 框架,它们还可以用于生成可用的 使用类似于以下代码的语言:
from zope.component import getUtility from zope.i18n.interfaces import ILanguageAvailability from zope.i18n.locales import locales, LoadLocaleError domain = 'myproject' def getLanguages(self): options = getUtility(ILanguageAvailability, domain).getAvailableLanguages() options.sort() result = [] for option in options: lang = option[0] try: locale = locales.getLocale(lang) except LoadLocaleError: # probably not a real locale continue result.append( {'code':lang, 'name':locale.displayNames.languages[lang],} ) return result
要求
Zope 2.12.0或更高版本是必需的。
安装
要安装,只需将包含在发行版中的sx文件夹 在你的Python身上。
配置
配置是通过zcml完成的,其中一个完整的示例是 显示如下:
<configure xmlns="http://namespaces.zope.org/zope" xmlns:i18n="http://namespaces.simplistix.co.uk/translations"> <!-- make the sx.translations' registerTranslations directive available --> <include package="sx.translations" file="meta.zcml" /> <!-- register our locales using sx.translations --> <i18n:registerTranslations locales="../locales" missing="../locales/myproj.pot" encoding="utf-8"/> </configure>
locales是指向包含区域设置的文件夹的路径 当前标准gnu gettext布局中的信息 由Zope 3支持。
missing是将未翻译的msgid附加到其中的文件 .pot fortmat.
编码是可选的,并指定要用于 在“missing”属性中指定的文件。如果没有提供,则 默认使用utf-8。
许可
版权所有(c)2006-2009 Simplistix有限公司
本软件在麻省理工学院许可下发布: http://www.opensource.org/licenses/mit-license.html 有关详细信息,请参见license.txt。
更改
1.2(2009年4月16日)
- 找到丢失的msgid时记录日期
1.1(2009年4月12日)
- 为zope.i18n 3.7.0更新
1.0(2006年9月18日)
- 初始版本