Added property to get contact button label
authorThierry Florac <thierry.florac@onf.fr>
Tue, 20 Nov 2018 16:08:56 +0100
changeset 240 00334308efd4
parent 239 a6429e91f091
child 241 88e43c1723e1
Added property to get contact button label
src/pyams_default_theme/component/paragraph/contact.py
--- a/src/pyams_default_theme/component/paragraph/contact.py	Tue Nov 20 15:40:17 2018 +0100
+++ b/src/pyams_default_theme/component/paragraph/contact.py	Tue Nov 20 16:08:56 2018 +0100
@@ -21,6 +21,7 @@
 from pyams_content.features.renderer.interfaces import IContentRenderer
 from pyams_default_theme.component.paragraph.interfaces.contact import IContactParagraphDefaultRendererSettings
 from pyams_default_theme.features.renderer import BaseContentRenderer
+from pyams_i18n.interfaces import II18n
 from pyams_skin.layer import IPyAMSLayer
 from pyams_template.template import template_config
 from pyams_utils.adapter import adapter_config, get_annotation_adapter
@@ -87,3 +88,10 @@
     else:
         context_attrs = ('name', 'photo', 'company', 'address', 'phone_number', 'contact_email')
     i18n_context_attrs = ('title', 'charge',)
+
+    @property
+    def button_label(self):
+        label = II18n(self.settings).query_attribute('button_label', request=self.request)
+        if not label:
+            label = self.request.localizer.translate(_("contact-button-label", default="Contact"))
+        return label