I18n文件和图片 -- Zope 3内容组件
项目描述
此包为Zope 3的文件和图片内容组件提供扩展,允许内容本地化。
详细文档
I18nFile测试
首先,创建一个I18nFile实例
>>> print http(r""" ... POST /@@contents.html HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """, form={"type_name": "BrowserAdd__zope.app.i18nfile.i18nfile.I18nFile", ... "new_value": "i18nfile"}) HTTP/1.1 303 See Other ...
然后为默认(en)语言添加一些示例数据
>>> print http(r""" ... POST /i18nfile/edit.html HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """, form={"contentType": "text/plain", ... "defaultLanguage": "en", ... "language": "en", ... "newLanguage": "", ... "data": "English", ... "edit": "Save"}) HTTP/1.1 303 See Other ...
好的,现在我们可以在编辑表单中查看数据
>>> print http(r""" ... GET /i18nfile/editForm.html?language=en HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """) HTTP/1.1 200 OK ... <textarea ...>English</textarea> ...
以及作为文件内容
>>> print http(r""" ... GET /i18nfile/index.html HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """) HTTP/1.1 200 OK ... English
让我们添加新的(俄语)语言
>>> print http(r""" ... POST /i18nfile/edit.html HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """, form={"contentType": "text/plain", ... "defaultLanguage": "en", ... "language": "en", ... "addLanguage": "Add new language", ... "newLanguage": "ru", ... "data": "English"}) HTTP/1.1 303 See Other ...
并为俄语(ru)语言添加一些示例数据
>>> print http(r""" ... POST /i18nfile/edit.html HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """, form={"contentType": "text/plain", ... "defaultLanguage": "en", ... "language": "ru", ... "newLanguage": "", ... "data": "Russian", ... "edit": "Save"}) HTTP/1.1 303 See Other ...
然后我们可以在编辑表单中查看俄语语言的示例数据
>>> print http(r""" ... GET /i18nfile/editForm.html?language=ru HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """) HTTP/1.1 200 OK ... <textarea ...>Russian</textarea> ...
如果我们的首选语言是俄语,我们还可以在文件内容中查看
>>> print http(r""" ... GET /i18nfile/index.html HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... Accept-Language: ru,en ... """) HTTP/1.1 200 OK ... Russian
I18nImage测试
首先,创建一个I18nImage实例
>>> print http(r""" ... POST /@@contents.html HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """, form={ ... "type_name": "BrowserAdd__zope.app.i18nfile.i18nimage.I18nImage", ... "new_value": "i18nimage"}) HTTP/1.1 303 See Other ...
然后为默认(en)语言添加一些示例图像数据
>>> print http(r""" ... POST /i18nimage/uploadAction.html HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """, form={"contentType": "image/gif", ... "defaultLanguage": "en", ... "language": "en", ... "newLanguage": "", ... "data": 'GIF89aENEN', ... "edit": "Save"}) HTTP/1.1 303 See Other ...
好的,现在我们可以在编辑表单中查看图像大小
>>> print http(r""" ... GET /i18nimage/upload.html?language=en HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """) HTTP/1.1 200 OK ... ...>1 KB 20037x20037</... ...
以及作为文件内容的图像数据
>>> print http(r""" ... GET /i18nimage/ HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """) HTTP/1.1 200 OK Content-Length: 10 Content-Type: image/gif <BLANKLINE> GIF89aENEN
让我们添加新的(俄语)语言
>>> print http(r""" ... POST /i18nimage/uploadAction.html HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """, form={"contentType": "image/gif", ... "defaultLanguage": "en", ... "language": "en", ... "addLanguage": "Add new language", ... "newLanguage": "ru", ... "data": ""}) HTTP/1.1 303 See Other ...
并为俄语(ru)语言添加一些示例图像数据
>>> print http(r""" ... POST /i18nimage/uploadAction.html HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """, form={"contentType": "image/gif", ... "defaultLanguage": "en", ... "language": "ru", ... "newLanguage": "", ... "data": "GIF89aRURU", ... "edit": "Save"}) HTTP/1.1 303 See Other ...
然后我们可以在编辑表单中查看俄语语言示例图像的大小
>>> print http(r""" ... GET /i18nimage/upload.html?language=ru HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... """) HTTP/1.1 200 OK ... ...>1 KB 21842x21842</... ...
如果我们的首选语言是俄语,我们可以在文件内容中查看图像
>>> print http(r""" ... GET /i18nimage/ HTTP/1.1 ... Authorization: Basic mgr:mgrpw ... Accept-Language: ru,en ... """) HTTP/1.1 200 OK Content-Length: 10 Content-Type: image/gif <BLANKLINE> GIF89aRURU
变更记录
3.4.1 (2007-10-31)
解决ZopeSecurityPolicy弃用警告。
3.4.0 (2007-10-24)
首次发布与主Zope树独立。
项目详情
关闭
zope.app.i18nfile-3.4.1.tar.gz 的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 92b29c423f479614f149002c0b2aa19ea586242f9d0603175ef37d50dc363ea9 |
|
MD5 | 295553b12f664ff88fcb3ff87d840a5b |
|
BLAKE2b-256 | dcf62b8aa1bf333fd3823d112a91c1f55e956342baa9d6e6b05650e8f2d44e81 |