Corrected I18n preview
authorThierry Florac <thierry.florac@onf.fr>
Wed, 13 Jun 2018 12:35:44 +0200
changeset 642 f2323704d6c3
parent 641 771482d50c94
child 643 6fa677b3456c
child 665 78a965e4fbb7
Corrected I18n preview
src/pyams_content/features/preview/zmi/templates/preview.pt
src/pyams_content/features/renderer/__init__.py
src/pyams_content/features/renderer/interfaces/__init__.py
src/pyams_content/features/renderer/zmi/__init__.py
--- a/src/pyams_content/features/preview/zmi/templates/preview.pt	Wed Jun 13 12:35:21 2018 +0200
+++ b/src/pyams_content/features/preview/zmi/templates/preview.pt	Wed Jun 13 12:35:44 2018 +0200
@@ -36,7 +36,7 @@
 								tal:attributes="class string:small ${active}">
 								<a data-toggle="tab" class="xsmall"
 								   tal:define="url extension:absolute_url(context, 'preview.html')"
-								   tal:attributes="src string:${url}?lang=${lang}">
+								   tal:attributes="href string:#preview-${lang}">
 									<img tal:attributes="src string:/--static--/pyams_i18n/img/flags/${lang}.png" />
 								</a>
 							</li>
--- a/src/pyams_content/features/renderer/__init__.py	Wed Jun 13 12:35:21 2018 +0200
+++ b/src/pyams_content/features/renderer/__init__.py	Wed Jun 13 12:35:44 2018 +0200
@@ -43,7 +43,11 @@
         """Get rendering adapter based on selected renderer name"""
         if request is None:
             request = check_request()
-        return request.registry.queryMultiAdapter((self, request), self.renderer_interface, name=self.renderer or '')
+        renderer = request.registry.queryMultiAdapter((self, request), self.renderer_interface,
+                                                      name=self.renderer or '')
+        if 'lang' in request.params:
+            renderer.language = request.params['lang']
+        return renderer
 
 
 @adapter_config(context=IRenderedContent, provides=IContentRenderer)
--- a/src/pyams_content/features/renderer/interfaces/__init__.py	Wed Jun 13 12:35:21 2018 +0200
+++ b/src/pyams_content/features/renderer/interfaces/__init__.py	Wed Jun 13 12:35:44 2018 +0200
@@ -41,6 +41,7 @@
     label = Attribute("Renderer label")
     weight = Attribute("Renderer weight")
     settings_interface = Attribute("Renderer target interface")
+    language = Attribute("Renderer language (if forced)")
 
 
 class ISharedContentRenderer(IContentRenderer):
--- a/src/pyams_content/features/renderer/zmi/__init__.py	Wed Jun 13 12:35:21 2018 +0200
+++ b/src/pyams_content/features/renderer/zmi/__init__.py	Wed Jun 13 12:35:44 2018 +0200
@@ -47,7 +47,6 @@
     def update(self):
         renderer = self.renderer
         if renderer is not None:
-            renderer.language = self.language
             renderer.update()
 
     def render(self):