[Checkins] SVN: grokcore.chameleon/trunk/ The target_language mangling was lost in version 1.0rc4. Copied from z3c.pt.
Jan-Jaap Driessen
cvs-admin at zope.org
Sun Apr 29 17:12:24 UTC 2012
Log message for revision 125420:
The target_language mangling was lost in version 1.0rc4. Copied from z3c.pt.
Changed:
U grokcore.chameleon/trunk/CHANGES.txt
U grokcore.chameleon/trunk/setup.py
U grokcore.chameleon/trunk/src/grokcore/chameleon/README.txt
U grokcore.chameleon/trunk/src/grokcore/chameleon/components.py
U grokcore.chameleon/trunk/src/grokcore/chameleon/ftesting.zcml
U grokcore.chameleon/trunk/src/grokcore/chameleon/tests/cpt_fixture/app.py
A grokcore.chameleon/trunk/src/grokcore/chameleon/tests/cpt_fixture/app_templates/menu.cpt
A grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/
A grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/de/
A grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/de/LC_MESSAGES/
A grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/de/LC_MESSAGES/grokcore-chameleon-tests.mo
A grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/de/LC_MESSAGES/grokcore-chameleon-tests.po
A grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/en/
A grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/en/LC_MESSAGES/
A grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/en/LC_MESSAGES/grokcore-chameleon-tests.mo
A grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/en/LC_MESSAGES/grokcore-chameleon-tests.po
-=-
Modified: grokcore.chameleon/trunk/CHANGES.txt
===================================================================
--- grokcore.chameleon/trunk/CHANGES.txt 2012-04-29 17:00:52 UTC (rev 125419)
+++ grokcore.chameleon/trunk/CHANGES.txt 2012-04-29 17:12:21 UTC (rev 125420)
@@ -4,9 +4,8 @@
1.0rc5 (unreleased)
===================
-- Nothing changed yet.
+- The ``target_language`` mangling was lost in version 1.0rc4. Copied from z3c.pt.
-
1.0rc4 (2012-01-03)
===================
Modified: grokcore.chameleon/trunk/setup.py
===================================================================
--- grokcore.chameleon/trunk/setup.py 2012-04-29 17:00:52 UTC (rev 125419)
+++ grokcore.chameleon/trunk/setup.py 2012-04-29 17:12:21 UTC (rev 125420)
@@ -9,6 +9,7 @@
'grokcore.view',
'Chameleon >= 2.0-rc1',
'z3c.pt >= 2.0-rc1',
+ 'zope.i18n',
]
tests_require = [
Modified: grokcore.chameleon/trunk/src/grokcore/chameleon/README.txt
===================================================================
--- grokcore.chameleon/trunk/src/grokcore/chameleon/README.txt 2012-04-29 17:00:52 UTC (rev 125419)
+++ grokcore.chameleon/trunk/src/grokcore/chameleon/README.txt 2012-04-29 17:12:21 UTC (rev 125420)
@@ -365,6 +365,40 @@
</body>
</html>
+Translation
+===========
+
+ >>> # Monkeypatch zope.i18n.negotiate
+ >>> import zope.i18n
+ >>> import zope.i18n.config
+ >>> print getMultiAdapter((manfred, request), name='menu')()
+ <html>
+ <body>
+ <h1>Menu</h1>
+ <ol>
+ <li>Deepfried breaded veal cutlets</li>
+ </ol>
+ </body>
+ </html>
+
+ >>> # What's for food today in Germany?
+ >>> # We need to monkey patch the language settings for this test.
+ >>> old_1, old_2 = zope.i18n.negotiate, zope.i18n.config.ALLOWED_LANGUAGES
+ >>> zope.i18n.negotiate = lambda context: 'de'
+ >>> zope.i18n.config.ALLOWED_LANGUAGES = ['de']
+ >>> print getMultiAdapter((manfred, request), name='menu')()
+ <html>
+ <body>
+ <h1>Menu</h1>
+ <ol>
+ <li>Schnitzel</li>
+ </ol>
+ </body>
+ </html>
+
+ >>> # Restore the monkey patch.
+ >>> zope.i18n.negotiate, zope.i18n.config.ALLOWED_LANGUAGES = old_1, old_2
+
Macros
======
Modified: grokcore.chameleon/trunk/src/grokcore/chameleon/components.py
===================================================================
--- grokcore.chameleon/trunk/src/grokcore/chameleon/components.py 2012-04-29 17:00:52 UTC (rev 125419)
+++ grokcore.chameleon/trunk/src/grokcore/chameleon/components.py 2012-04-29 17:12:21 UTC (rev 125420)
@@ -20,6 +20,7 @@
from grokcore.component import GlobalUtility, implements, name
from grokcore.view import interfaces
from grokcore.view.components import GrokTemplate
+import zope.i18n
from chameleon.zpt.template import PageTemplate, PageTemplateFile
from chameleon.tales import PythonExpr
from chameleon.tales import StringExpr
@@ -85,9 +86,17 @@
return self._template.macros
def render(self, view):
- return self._template(**self.getNamespace(view))
+ context = self.getNamespace(view)
+ if 'target_language' not in context:
+ try:
+ target_language = zope.i18n.negotiate(context['request'])
+ except:
+ target_language = None
+ context['target_language'] = target_language
+ return self._template(**context)
+
class ChameleonPageTemplateFile(ChameleonPageTemplate):
def __init__(self, filename, _prefix=None):
@@ -103,4 +112,4 @@
name('cpt')
def __call__(self, filename, _prefix=None):
- return ChameleonPageTemplate(filename=filename, _prefix=_prefix)
\ No newline at end of file
+ return ChameleonPageTemplate(filename=filename, _prefix=_prefix)
Modified: grokcore.chameleon/trunk/src/grokcore/chameleon/ftesting.zcml
===================================================================
--- grokcore.chameleon/trunk/src/grokcore/chameleon/ftesting.zcml 2012-04-29 17:00:52 UTC (rev 125419)
+++ grokcore.chameleon/trunk/src/grokcore/chameleon/ftesting.zcml 2012-04-29 17:12:21 UTC (rev 125420)
@@ -1,18 +1,24 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:grok="http://namespaces.zope.org/grok"
- i18n_domain="grokcore.chameleon"
+ xmlns:i18n="http://namespaces.zope.org/i18n"
+ i18n_domain="grokcore-chameleon-tests"
package="grokcore.chameleon">
<include package="zope.component" file="meta.zcml"/>
<include package="zope.security" file="meta.zcml"/>
+ <include package="zope.i18n" file="meta.zcml" />
<include package="zope.browserpage" file="meta.zcml"/>
<include package="grokcore.viewlet" file="meta.zcml" />
<include package="zope.traversing"/>
<include package="zope.traversing.browser"/>
<include package="zope.container"/>
+ <include package="zope.i18n" />
<include package="zope.app.appsetup"/>
<include package="grokcore.viewlet"/>
<include package="grokcore.chameleon"/>
+
+ <i18n:registerTranslations directory="tests/locale" />
+
</configure>
Modified: grokcore.chameleon/trunk/src/grokcore/chameleon/tests/cpt_fixture/app.py
===================================================================
--- grokcore.chameleon/trunk/src/grokcore/chameleon/tests/cpt_fixture/app.py 2012-04-29 17:00:52 UTC (rev 125419)
+++ grokcore.chameleon/trunk/src/grokcore/chameleon/tests/cpt_fixture/app.py 2012-04-29 17:12:21 UTC (rev 125420)
@@ -54,3 +54,6 @@
def namespace(self):
return {'myname': 'Henk'}
+
+class Menu(grokcore.view.View):
+ pass
Added: grokcore.chameleon/trunk/src/grokcore/chameleon/tests/cpt_fixture/app_templates/menu.cpt
===================================================================
--- grokcore.chameleon/trunk/src/grokcore/chameleon/tests/cpt_fixture/app_templates/menu.cpt (rev 0)
+++ grokcore.chameleon/trunk/src/grokcore/chameleon/tests/cpt_fixture/app_templates/menu.cpt 2012-04-29 17:12:21 UTC (rev 125420)
@@ -0,0 +1,9 @@
+<html xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+ i18n:domain="grokcore-chameleon-tests">
+<body>
+ <h1>Menu</h1>
+ <ol>
+ <li i18n:translate="">Deepfried breaded veal cutlets</li>
+ </ol>
+</body>
+</html>
Added: grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/de/LC_MESSAGES/grokcore-chameleon-tests.mo
===================================================================
(Binary files differ)
Property changes on: grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/de/LC_MESSAGES/grokcore-chameleon-tests.mo
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/de/LC_MESSAGES/grokcore-chameleon-tests.po
===================================================================
--- grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/de/LC_MESSAGES/grokcore-chameleon-tests.po (rev 0)
+++ grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/de/LC_MESSAGES/grokcore-chameleon-tests.po 2012-04-29 17:12:21 UTC (rev 125420)
@@ -0,0 +1,11 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: Zope 3\n"
+"PO-Revision-Date: 2002/06/13\n"
+"Last-Translator: Zope 3 contributors\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Deepfried breaded veal cutlets"
+msgstr "Schnitzel"
Added: grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/en/LC_MESSAGES/grokcore-chameleon-tests.mo
===================================================================
(Binary files differ)
Property changes on: grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/en/LC_MESSAGES/grokcore-chameleon-tests.mo
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/en/LC_MESSAGES/grokcore-chameleon-tests.po
===================================================================
--- grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/en/LC_MESSAGES/grokcore-chameleon-tests.po (rev 0)
+++ grokcore.chameleon/trunk/src/grokcore/chameleon/tests/locale/en/LC_MESSAGES/grokcore-chameleon-tests.po 2012-04-29 17:12:21 UTC (rev 125420)
@@ -0,0 +1,11 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: Zope 3\n"
+"PO-Revision-Date: 2002/06/13\n"
+"Last-Translator: Zope 3 contributors\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+msgid "Deepfried breaded veal cutlets"
+msgstr "Deepfried breaded veal cutlets"
More information about the checkins
mailing list