[Checkins] SVN: megrok.jinja/trunk/README.txt Update README for 0.1 release

Santiago Videla santiago.videla at gmail.com
Sun May 3 12:55:13 EDT 2009


Log message for revision 99680:
  Update README for 0.1 release
  
  

Changed:
  U   megrok.jinja/trunk/README.txt

-=-
Modified: megrok.jinja/trunk/README.txt
===================================================================
--- megrok.jinja/trunk/README.txt	2009-05-03 06:40:07 UTC (rev 99679)
+++ megrok.jinja/trunk/README.txt	2009-05-03 16:55:13 UTC (rev 99680)
@@ -21,7 +21,7 @@
 
 To use the Jinja2 templates within Grok, megrok.jinja must be first
 installed as an egg, and its ZCML included. After using grokproject,
-amend the setup.py to look like this:
+amend the setup.py to look like this::
 
     install_requires=[''setuptools',
                       'grok',
@@ -50,7 +50,7 @@
 Jinja2 Environment
 ------------------
 
-megrok.jinja create an Environment using `jinja2.ext.i18n` extension and overrides
+megrok.jinja creates an Environment using `jinja2.ext.i18n` extension and overrides
 the globals variables `_` and `gettext` in order to use custom functions to resolve
 translations. It also set the global variable `provider` as a function to resolve
 the call to a content provider (viewlet manager).
@@ -79,6 +79,48 @@
     Whatever you may want to translate.
     {% endtrans %}
 
+
+It's important to note that, `messages` created in python classes
+won't be translated like in Zope Page Templates.
+
+If you write:
+
+view.py::
+
+    from zope import i18nmessageid
+    _ = i18nmessageid.MessageFactory('some.domain')
+
+    class Something(grok.View):
+        def update(self):
+            self.msg = _('Some msg id')
+
+view.jinja::
+
+    {{ view.msg }}
+
+You will always get 'Some msg id'. What you do could write is:
+
+view.py::
+
+    class Something(grok.View):
+        def update(self):
+            self.msg = 'Some msg id'
+
+view.jinja::
+
+    {% set i18n_domain='some.domain' %}
+
+    {{ _(view.msg) }}
+
+Note that megrok.jinja uses the `translate` function from
+zope.i18n.interfaces.ITranslationDomains, so using::
+
+    {{ _('msg_id') }}
+
+you can pass all the parameters accepted by `translate`::
+
+    {{ _('msg_id', domain='another_domain', target_language='es') }}
+
 If you want to call some content provider named 'manager', just write::
 
     {{ provider('manager') }}
@@ -114,41 +156,6 @@
                 {"key-4": "whatever 4"}]}
 
 
-TODO
------
-It's important to note that, `messages` created in python classes
-won't be translated like in Zope Page Templates.
-
-If you write:
-
-view.py::
-
-    from zope import i18nmessageid
-    _ = i18nmessageid.MessageFactory('some.domain')
-
-    class Something(grok.View):
-        def update(self):
-            self.msg = _('Some msg id')
-
-view.jinja::
-
-    {{ view.msg }}
-
-You will always get 'Some msg id'.
-What you do could write is
-
-view.py::
-
-    class Something(grok.View):
-        def update(self):
-            self.msg = 'Some msg id'
-
-view.jinja::
-
-    {% set i18n_domain='some.domain' %}
-
-    {{ _(view.msg) }}
-
 Authors
 -------
 



More information about the Checkins mailing list