From 9ee7bdaec55404cecb2e0d46f248e3aff3c338d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Thu, 16 Feb 2023 10:47:08 +0000 Subject: [PATCH] [FIX] im_livechat: translate livechat button text per user language MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, the livechat button text was not considering the language of the user for translation. The translation must not be loaded at field initialization, but when the value is accessed e.g. from a livechat visitor. closes odoo/odoo#112936 X-original-commit: 48dbf94068e09d831e4bf262b70b11adaade4b57 Signed-off-by: Sébastien Theys (seb) Signed-off-by: Alexandre Kühn (aku) --- addons/im_livechat/i18n/im_livechat.pot | 1 + addons/im_livechat/models/im_livechat_channel.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/im_livechat/i18n/im_livechat.pot b/addons/im_livechat/i18n/im_livechat.pot index f52a03f0670..0d65ef2e935 100644 --- a/addons/im_livechat/i18n/im_livechat.pot +++ b/addons/im_livechat/i18n/im_livechat.pot @@ -814,6 +814,7 @@ msgstr "" #. module: im_livechat #. odoo-javascript #: code:addons/im_livechat/static/src/public_models/livechat_button_view.js:0 +#: code:addons/im_livechat/models/im_livechat_channel.py:0 #, python-format msgid "How may I help you?" msgstr "" diff --git a/addons/im_livechat/models/im_livechat_channel.py b/addons/im_livechat/models/im_livechat_channel.py index 303a86f5dd0..14ac166b396 100644 --- a/addons/im_livechat/models/im_livechat_channel.py +++ b/addons/im_livechat/models/im_livechat_channel.py @@ -26,11 +26,17 @@ class ImLivechatChannel(models.Model): def _default_user_ids(self): return [(6, 0, [self._uid])] + def _default_button_text(self): + return _('Have a Question? Chat with us.') + + def _default_default_message(self): + return _('How may I help you?') + # attribute fields name = fields.Char('Channel Name', required=True) - button_text = fields.Char('Text of the Button', default=_('Have a Question? Chat with us.'), + button_text = fields.Char('Text of the Button', default=_default_button_text, help="Default text displayed on the Livechat Support Button", translate=True) - default_message = fields.Char('Welcome Message', default='How may I help you?', + default_message = fields.Char('Welcome Message', default=_default_default_message, help="This is an automated 'welcome' message that your visitor will see when they initiate a new conversation.", translate=True) input_placeholder = fields.Char('Chat Input Placeholder', help='Text that prompts the user to initiate the chat.', translate=True) header_background_color = fields.Char(default="#875A7B", help="Default background color of the channel header once open")