[Testbot] Plone 5.0 - Python 2.7 - Build # 2944 - Still failing! - 0 failure(s)

jenkins at plone.org jenkins at plone.org
Sat Aug 9 18:09:30 UTC 2014


-------------------------------------------------------------------------------
Plone 5.0 - Python 2.7 - Build # 2944 - Still Failing!
-------------------------------------------------------------------------------

http://jenkins.plone.org/job/plone-5.0-python-2.7/2944/


-------------------------------------------------------------------------------
CHANGES
-------------------------------------------------------------------------------

Repository: plone.app.widgets
Branch: refs/heads/master
Date: 2014-08-09T18:53:03+02:00
Author: Nathan Van Gheem (vangheem) <vangheem at gmail.com>
Commit: https://github.com/plone/plone.app.widgets/commit/4b397c36b17fdcebf6b384d8fdffa9420857e284

add plone i18n integration

Files changed:
A plone/app/widgets/browser/i18n.py
M CHANGES.rst
M plone/app/widgets/browser/configure.zcml

diff --git a/CHANGES.rst b/CHANGES.rst
index c1811ee..da3043e 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -7,6 +7,9 @@ Changelog
 - Test fixes.
   [thet]
 
+- add jsi18n integration
+  [vangheem]
+
 
 1.7.0 (2014-07-15)
 ------------------
diff --git a/plone/app/widgets/browser/configure.zcml b/plone/app/widgets/browser/configure.zcml
index d681e53..efea02e 100644
--- a/plone/app/widgets/browser/configure.zcml
+++ b/plone/app/widgets/browser/configure.zcml
@@ -43,4 +43,11 @@
     permission="zope.Public"
     />
 
+  <browser:view
+    for="Products.CMFPlone.interfaces.IPloneSiteRoot"
+    name="plonejsi18n"
+    class=".i18n.i18njs"
+    permission="zope2.View"
+    />
+
 </configure>
diff --git a/plone/app/widgets/browser/i18n.py b/plone/app/widgets/browser/i18n.py
new file mode 100644
index 0000000..612b510
--- /dev/null
+++ b/plone/app/widgets/browser/i18n.py
@@ -0,0 +1,38 @@
+import json
+
+from plone.memoize import ram
+from zope.component import queryUtility
+from zope.i18n.interfaces import ITranslationDomain
+
+from Products.Five.browser import BrowserView
+
+
+def _cache_key(method, self, domain, language):
+    return (domain, language,)
+
+
+class i18njs(BrowserView):
+
+    @ram.cache(_cache_key)
+    def _gettext_catalog(self, domain, language):
+        td = queryUtility(ITranslationDomain, domain)
+        if td is None or language not in td._catalogs:
+            return
+        mo_path = td._catalogs[language][0]
+        catalog = td._data[mo_path]._catalog
+        if catalog is None:
+            td._data[mo_path].reload()
+            catalog = td._data[mo_path]._catalog
+        return catalog._catalog
+
+    def __call__(self, domain, language=None):
+        if domain is None:
+            return
+        if language is None:
+            language = self.request['LANGUAGE']
+
+        catalog = self._gettext_catalog(domain, language)
+        response = self.request.response
+        response.setHeader('content-type', 'application/json')
+        response.setBody(json.dumps(catalog))
+        return response
\ No newline at end of file




-------------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CHANGES.log
Type: application/octet-stream
Size: 2484 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20140809/32e7f901/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: build.log
Type: application/octet-stream
Size: 145368 bytes
Desc: not available
URL: <http://lists.plone.org/pipermail/plone-testbot/attachments/20140809/32e7f901/attachment-0003.obj>


More information about the Testbot mailing list