[Checkins] SVN: z3c.pt/trunk/src/z3c/pt/ Removing test; it's been moved to chameleon.zpt.
Malthe Borch
mborch at gmail.com
Thu Oct 30 12:40:16 EDT 2008
Log message for revision 92709:
Removing test; it's been moved to chameleon.zpt.
Changed:
D z3c.pt/trunk/src/z3c/pt/i18n.txt
U z3c.pt/trunk/src/z3c/pt/tests/test_doctests.py
-=-
Deleted: z3c.pt/trunk/src/z3c/pt/i18n.txt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/i18n.txt 2008-10-30 16:38:22 UTC (rev 92708)
+++ z3c.pt/trunk/src/z3c/pt/i18n.txt 2008-10-30 16:40:15 UTC (rev 92709)
@@ -1,314 +0,0 @@
-i18n
-----
-
-This document highlights the i18n-support in the engine. The
-implementation is based on this document:
-
- * http://wiki.zope.org/zope3/ZPTInternationalizationSupport
-
-With the exception of i18n:data and i18n:source, the implementation is
-complete.
-
-Let's provide German mock translations for all msgids:
-
- >>> from zope import component
- >>> from zope import interface
-
- >>> from zope.i18n.interfaces import ITranslationDomain
- >>> class MockTranslationDomain(object):
- ... interface.implements(ITranslationDomain)
- ...
- ... def translate(self, msgid, mapping=None, context=None,
- ... target_language=None, default=None):
- ... if target_language != 'de':
- ... return default
- ...
- ... mock ="Mock translation of '%s'" % msgid
- ... if mapping:
- ... mock += ' mapping=%s' % mapping
- ... return mock + '.'
-
- >>> td = MockTranslationDomain()
- >>> component.provideUtility(td, ITranslationDomain, name="test")
-
-Translation of tag contents
----------------------------
-
-First, a simple example:
-
- >>> body = """\
- ... <div xmlns="http://www.w3.org/1999/xhtml"
- ... xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- ... <span i18n:domain="test" i18n:translate="test_msgid">
- ... Default
- ... </span>
- ... </div>"""
-
-First we need to turn the template into a callable:
-
- >>> from z3c.pt.pagetemplate import PageTemplate
- >>> template = PageTemplate(body)
-
-Let's try rendering this template without passing a target language.
-
- >>> print template.render()
- <div>
- <span>
- Default
- </span>
- </div>
-
-Now we'll render the template again---passing German as the language.
-
- >>> print template.render(target_language='de')
- <div>
- <span>Mock translation of 'test_msgid'.</span>
- </div>
-
-Let's try infering the translation message id from the tag body.
-
- >>> body = """\
- ... <div xmlns="http://www.w3.org/1999/xhtml"
- ... xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- ... <span i18n:domain="test" i18n:translate="">
- ... Default
- ... </span>
- ... </div>"""
-
-Not passing a language:
-
- >>> template = PageTemplate(body)
- >>> print template.render()
- <div>
- <span>
- Default
- </span>
- </div>
-
-Passing German:
-
- >>> print template.render(target_language='de')
- <div>
- <span>Mock translation of 'Default'.</span>
- </div>
-
-We could also add a named block inside the tag.
-
- >>> body = """\
- ... <div xmlns="http://www.w3.org/1999/xhtml"
- ... xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- ... <p i18n:domain="test" i18n:translate="">
- ... <span i18n:name="count">18</span> bananas.
- ... </p>
- ... </div>"""
-
- >>> template = PageTemplate(body)
- >>> print template.render()
- <div>
- <p>
- <span>18</span> bananas.
- </p>
- </div>
-
- >>> print template.render(target_language='de')
- <div>
- <p>Mock translation of '${count} bananas.'
- mapping={'count': '<span>18</span>'}
- </p>
- </div>
-
-Or two:
-
- >>> body = """\
- ... <div xmlns="http://www.w3.org/1999/xhtml"
- ... xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- ... <span i18n:domain="test" i18n:translate="">
- ... I want <span i18n:name="bananas">12</span> bananas and
- ... <span i18n:name="apples">8</span> apples.
- ... </span>
- ... </div>"""
-
-Without a language this gives:
-
- >>> template = PageTemplate(body)
- >>> print template.render()
- <div>
- <span>
- I want <span>12</span> bananas and
- <span>8</span> apples.
- </span>
- </div>
-
-In German:
-
- >>> print template.render(target_language='de')
- <div>
- <span>
- Mock translation of 'I want ${bananas} bananas and ${apples} apples.'
- mapping={'bananas': '<span>12</span>', 'apples': '<span>8</span>'}.
- </span>
- </div>
-
-
-Translation of tag attributes
------------------------------
-
-A simple example to start with.
-
- >>> body = """\
- ... <div xmlns="http://www.w3.org/1999/xhtml"
- ... xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- ... <span i18n:domain="test" title="Simple Title" i18n:attributes="title">
- ... Default
- ... </span>
- ... </div>"""
-
-Not passing a language:
-
- >>> template = PageTemplate(body)
- >>> print template.render()
- <div>
- <span title="Simple Title">
- Default
- </span>
- </div>
-
-Passing German:
-
- >>> print template.render(target_language='de')
- <div>
- <span title="Mock translation of 'Simple Title'.">
- Default
- </span>
- </div>
-
-Use an explicit msgid:
-
- >>> body = """\
- ... <div xmlns="http://www.w3.org/1999/xhtml"
- ... xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- ... <span i18n:domain="test" title="Simple Title"
- ... i18n:attributes="title title_simple">
- ... Default
- ... </span>
- ... </div>"""
-
-Not passing a language:
-
- >>> template = PageTemplate(body)
- >>> print template.render()
- <div>
- <span title="Simple Title">
- Default
- </span>
- </div>
-
-Passing German:
-
- >>> print template.render(target_language='de')
- <div>
- <span title="Mock translation of 'title_simple'.">
- Default
- </span>
- </div>
-
-Use an explicit msgid with a trailing semicolon.
-
- >>> body = """\
- ... <div xmlns="http://www.w3.org/1999/xhtml"
- ... xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- ... <span i18n:domain="test" title="Simple Title"
- ... i18n:attributes="title title_simple;">
- ... Default
- ... </span>
- ... </div>"""
-
-Not passing a language:
-
- >>> template = PageTemplate(body)
- >>> print template.render()
- <div>
- <span title="Simple Title">
- Default
- </span>
- </div>
-
-Passing German:
-
- >>> print template.render(target_language='de')
- <div>
- <span title="Mock translation of 'title_simple'.">
- Default
- </span>
- </div>
-
-Use multiple attributes on the same tag.
-
- >>> body = """\
- ... <div xmlns="http://www.w3.org/1999/xhtml"
- ... xmlns:i18n="http://xml.zope.org/namespaces/i18n">
- ... <span i18n:domain="test" title="Simple Title"
- ... longdesc="A not so short description."
- ... i18n:attributes="title title_simple; longdesc desc_short">
- ... Default
- ... </span>
- ... </div>"""
-
-Not passing a language:
-
- >>> template = PageTemplate(body)
- >>> print template.render()
- <div>
- <span title="Simple Title" longdesc="A not so short description.">
- Default
- </span>
- </div>
-
-Passing German:
-
- >>> print template.render(target_language='de')
- <div>
- <span title="Mock translation of 'title_simple'."
- longdesc="Mock translation of 'desc_short'.">
- Default
- </span>
- </div>
-
-Translation of tag content and tag attributes
----------------------------------------------
-
-A simple example to start with.
-
- >>> body = """\
- ... <div xmlns="http://www.w3.org/1999/xhtml"
- ... xmlns:i18n="http://xml.zope.org/namespaces/i18n"
- ... xmlns:tal="http://xml.zope.org/namespaces/tal">
- ... <span i18n:domain="test" i18n:translate="tid"
- ... title="Title" i18n:attributes="title aid">
- ... Default, "default", 'default'
- ... </span>
- ... <span i18n:domain="test" i18n:translate=""
- ... tal:content="string:tid">
- ... Default, "default", 'default'
- ... </span>
- ... </div>"""
-
-Not passing a language:
-
- >>> template = PageTemplate(body)
- >>> print template.render()
- <div>
- <span title="Title">
- Default, "default", 'default'
- </span>
- <span>tid</span>
- </div>
-
-Passing German:
-
- >>> print template.render(target_language='de')
- <div>
- <span title="Mock translation of 'aid'.">Mock translation of 'tid'.</span>
- <span>Mock translation of 'tid'.</span>
- </div>
-
Modified: z3c.pt/trunk/src/z3c/pt/tests/test_doctests.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/tests/test_doctests.py 2008-10-30 16:38:22 UTC (rev 92708)
+++ z3c.pt/trunk/src/z3c/pt/tests/test_doctests.py 2008-10-30 16:40:15 UTC (rev 92709)
@@ -15,7 +15,7 @@
zope.configuration.xmlconfig.XMLConfig('configure.zcml', z3c.pt)()
def test_suite():
- filesuites = 'README.txt', 'i18n.txt',
+ filesuites = 'README.txt'
testsuites = 'z3c.pt.expressions',
config.DISK_CACHE = False
More information about the Checkins
mailing list