diff options
| author | Martin Trigaux <mat@odoo.com> | 2021-02-04 09:40:00 +0000 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2021-02-04 09:40:00 +0000 |
| commit | 80f05addf48dd57da9ae78f39116a9b23f60529a (patch) | |
| tree | e064f86f2731e4b7d3a25ea21d4b271939f704d2 /addons | |
| parent | 6e880c891d3066e0fcc9f1509f914a7ba483d618 (diff) | |
[FIX] mail: fallback on English message
In case of bad translation that doesn't contain the placeholder
Context:
A bad Japanese translation was inserted
#. module: mail
#: code:addons/mail/models/mail_thread.py:0
#, python-format
msgid "Create new %(document)s"
msgstr "新しい%(ドキュメント)を作成する"
The translation has been corrected but use the 14.0 syntax of _ method
to include placeholders and fallback on the English source term in
case of bad translation
cf odoo/odoo#52155
closes odoo/odoo#65517
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/mail/models/mail_channel.py | 22 | ||||
| -rw-r--r-- | addons/mail/models/mail_message.py | 4 | ||||
| -rw-r--r-- | addons/mail/models/mail_render_mixin.py | 2 | ||||
| -rw-r--r-- | addons/mail/models/mail_thread.py | 20 |
4 files changed, 23 insertions, 25 deletions
diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index a75a9204dd1..778b362a893 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -329,7 +329,7 @@ class Channel(models.Model): channel_info['is_pinned'] = False self.env['bus.bus'].sendone((self._cr.dbname, 'res.partner', partner.id), channel_info) if not self.email_send: - notification = _('<div class="o_mail_notification">left <a href="#" class="o_channel_redirect" data-oe-id="%s">#%s</a></div>') % (self.id, self.name,) + notification = _('<div class="o_mail_notification">left <a href="#" class="o_channel_redirect" data-oe-id="%s">#%s</a></div>', self.id, self.name) # post 'channel left' message as root since the partner just unsubscribed from the channel self.sudo().message_post(body=notification, subtype_xmlid="mail.mt_comment", author_id=partner.id) return result @@ -856,14 +856,14 @@ class Channel(models.Model): channel.write({'channel_last_seen_partner_ids': [(0, 0, {'partner_id': partner_id}) for partner_id in partners_to_add.ids]}) for partner in partners_to_add: if partner.id != self.env.user.partner_id.id: - notification = _('<div class="o_mail_notification">%(author)s invited %(new_partner)s to <a href="#" class="o_channel_redirect" data-oe-id="%(channel_id)s">#%(channel_name)s</a></div>') % { - 'author': self.env.user.display_name, - 'new_partner': partner.display_name, - 'channel_id': channel.id, - 'channel_name': channel.name, - } + notification = _('<div class="o_mail_notification">%(author)s invited %(new_partner)s to <a href="#" class="o_channel_redirect" data-oe-id="%(channel_id)s">#%(channel_name)s</a></div>', + author=self.env.user.display_name, + new_partner=partner.display_name, + channel_id=channel.id, + channel_name=channel.name, + ) else: - notification = _('<div class="o_mail_notification">joined <a href="#" class="o_channel_redirect" data-oe-id="%s">#%s</a></div>') % (channel.id, channel.name,) + notification = _('<div class="o_mail_notification">joined <a href="#" class="o_channel_redirect" data-oe-id="%s">#%s</a></div>', channel.id, channel.name) self.message_post(body=notification, message_type="notification", subtype_xmlid="mail.mt_comment", author_id=partner.id, notify_by_email=False) # broadcast the channel header to the added partner @@ -970,7 +970,7 @@ class Channel(models.Model): self.ensure_one() added = self.action_follow() if added and self.channel_type == 'channel' and not self.email_send: - notification = _('<div class="o_mail_notification">joined <a href="#" class="o_channel_redirect" data-oe-id="%s">#%s</a></div>') % (self.id, self.name,) + notification = _('<div class="o_mail_notification">joined <a href="#" class="o_channel_redirect" data-oe-id="%s">#%s</a></div>', self.id, self.name) self.message_post(body=notification, message_type="notification", subtype_xmlid="mail.mt_comment") if added and self.moderation_guidelines: @@ -994,7 +994,7 @@ class Channel(models.Model): 'public': privacy, 'email_send': False, }) - notification = _('<div class="o_mail_notification">created <a href="#" class="o_channel_redirect" data-oe-id="%s">#%s</a></div>') % (new_channel.id, new_channel.name,) + notification = _('<div class="o_mail_notification">created <a href="#" class="o_channel_redirect" data-oe-id="%s">#%s</a></div>', new_channel.id, new_channel.name) new_channel.message_post(body=notification, message_type="notification", subtype_xmlid="mail.mt_comment") channel_info = new_channel.channel_info('creation')[0] self.env['bus.bus'].sendone((self._cr.dbname, 'res.partner', self.env.user.partner_id.id), channel_info) @@ -1096,7 +1096,7 @@ class Channel(models.Model): else: all_channel_partners = self.env['mail.channel.partner'].with_context(active_test=False) channel_partners = all_channel_partners.search([('partner_id', '!=', partner.id), ('channel_id', '=', self.id)]) - msg = _("You are in a private conversation with <b>@%s</b>.") % (channel_partners[0].partner_id.name if channel_partners else _('Anonymous')) + msg = _("You are in a private conversation with <b>@%s</b>.", channel_partners[0].partner_id.name if channel_partners else _('Anonymous')) msg += _("""<br><br> Type <b>@username</b> to mention someone, and grab his attention.<br> Type <b>#channel</b> to mention a channel.<br> diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index 0d2970dc15f..2eee9623fb2 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -367,7 +367,7 @@ class Message(models.Model): message.id = ANY (%%s)''' % (self._table), ('comment', self.ids,)) if self._cr.fetchall(): raise AccessError( - _('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % (self._description, operation) + _('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)', self._description, operation) + ' - ({} {}, {} {})'.format(_('Records:'), self.ids[:6], _('User:'), self._uid) ) @@ -580,7 +580,7 @@ class Message(models.Model): if not self.browse(messages_to_check).exists(): return raise AccessError( - _('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)') % (self._description, operation) + _('The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: %s, Operation: %s)', self._description, operation) + ' - ({} {}, {} {})'.format(_('Records:'), list(messages_to_check)[:6], _('User:'), self._uid) ) diff --git a/addons/mail/models/mail_render_mixin.py b/addons/mail/models/mail_render_mixin.py index 1d90284b8aa..0539716fe38 100644 --- a/addons/mail/models/mail_render_mixin.py +++ b/addons/mail/models/mail_render_mixin.py @@ -268,7 +268,7 @@ class MailRenderMixin(models.AbstractModel): render_result = view._render(variables, engine='ir.qweb', minimal_qcontext=True) except Exception as e: _logger.info("Failed to render template : %s (%d)" % (template_src, view.id), exc_info=True) - raise UserError(_("Failed to render template : %s (%d)") % (template_src, view.id)) + raise UserError(_("Failed to render template : %s (%d)", template_src, view.id)) results[record.id] = render_result return results diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 2b2cb9354a1..db478e10812 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -377,26 +377,24 @@ class MailThread(models.AbstractModel): email_link = "<a href='mailto:%(email)s'>%(email)s</a>" % {'email': alias.display_name} if nothing_here: return "<p class='o_view_nocontent_smiling_face'>%(dyn_help)s</p>" % { - 'dyn_help': _("Add a new %(document)s or send an email to %(email_link)s") % { - 'document': document_name, - 'email_link': email_link - } + 'dyn_help': _("Add a new %(document)s or send an email to %(email_link)s", + document=document_name, + email_link=email_link, + ) } # do not add alias two times if it was added previously if "oe_view_nocontent_alias" not in help: return "%(static_help)s<p class='oe_view_nocontent_alias'>%(dyn_help)s</p>" % { 'static_help': help, - 'dyn_help': _("Create new %(document)s by sending an email to %(email_link)s") % { - 'document': document_name, - 'email_link': email_link, - } + 'dyn_help': _("Create new %(document)s by sending an email to %(email_link)s", + document=document_name, + email_link=email_link, + ) } if nothing_here: return "<p class='o_view_nocontent_smiling_face'>%(dyn_help)s</p>" % { - 'dyn_help': _("Create new %(document)s") % { - 'document': document_name, - } + 'dyn_help': _("Create new %(document)s", document=document_name), } return help |
