diff options
| author | Odoo's Mergebot <xmo+roboto@odoo.com> | 2020-06-18 13:51:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-18 13:51:48 +0200 |
| commit | e617aa91c536093f481da28b0cf061a6abe55b2a (patch) | |
| tree | 74fbff684e24f5389db77e63ee74f236039a3afb /addons/sms/wizard/sms_composer.py | |
| parent | cb7a7deec5c1eda8c156e1b1f9e1f1e38d0abda2 (diff) | |
| parent | 80e97e98ce76067db1079af8feeef667cfadf837 (diff) | |
[MERGE] tools: better placeholder support for _
Support two new syntaxes with `_()` method:
_("This is so %s") % 2019
_("Text with %s placeholders", 42)
_("Text with %(num)s placeholders %(symbol)s", num=42, symbol="🧀")
The main benefit is to have a fallback on the source string if formating the
translated string fails (e.g. "Foo %s" translated "Foo s%").
This PR converted most (but not all) calls to _ using placeholders to use the
new syntax. Hopefully, the remaining ones will be converted in the future and
avoid technical debt.
Use named placeholders when needed. If more than one placeholder is present in a
string, using named placeholder can be beneficial to reorder the placehodler
position (for languages like Japanese that do not use the same phrase
construction). On some sentences, it also brings clarity on the meaning of the
placeholders.
closes odoo/odoo#52155
Task-id: 1853119
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons/sms/wizard/sms_composer.py')
| -rw-r--r-- | addons/sms/wizard/sms_composer.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/sms/wizard/sms_composer.py b/addons/sms/wizard/sms_composer.py index 0d3d822ed4b..7467d99a21a 100644 --- a/addons/sms/wizard/sms_composer.py +++ b/addons/sms/wizard/sms_composer.py @@ -155,7 +155,7 @@ class SendSMS(models.TransientModel): sanitized_numbers = [info['sanitized'] for info in sanitize_res.values() if info['sanitized']] invalid_numbers = [number for number, info in sanitize_res.items() if info['code']] if invalid_numbers: - raise UserError(_('Following numbers are not correctly encoded: %s') % repr(invalid_numbers)) + raise UserError(_('Following numbers are not correctly encoded: %s', repr(invalid_numbers))) composer.sanitized_numbers = ','.join(sanitized_numbers) else: composer.sanitized_numbers = False @@ -193,7 +193,7 @@ class SendSMS(models.TransientModel): if self.comment_single_recipient and not self.recipient_single_valid: raise UserError(_('Invalid recipient number. Please update it.')) elif not self.comment_single_recipient and self.recipient_invalid_count: - raise UserError(_('%s invalid recipients') % self.recipient_invalid_count) + raise UserError(_('%s invalid recipients', self.recipient_invalid_count)) self._action_send_sms() return False |
