summaryrefslogtreecommitdiff
path: root/addons/base_import/models/base_import.py
diff options
context:
space:
mode:
authorOdoo's Mergebot <xmo+roboto@odoo.com>2020-06-18 13:51:48 +0200
committerGitHub <noreply@github.com>2020-06-18 13:51:48 +0200
commite617aa91c536093f481da28b0cf061a6abe55b2a (patch)
tree74fbff684e24f5389db77e63ee74f236039a3afb /addons/base_import/models/base_import.py
parentcb7a7deec5c1eda8c156e1b1f9e1f1e38d0abda2 (diff)
parent80e97e98ce76067db1079af8feeef667cfadf837 (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/base_import/models/base_import.py')
-rw-r--r--addons/base_import/models/base_import.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/addons/base_import/models/base_import.py b/addons/base_import/models/base_import.py
index 041d5ef2dd1..d126bb4268e 100644
--- a/addons/base_import/models/base_import.py
+++ b/addons/base_import/models/base_import.py
@@ -297,7 +297,7 @@ class Import(models.TransientModel):
_("Invalid cell value at row %(row)s, column %(col)s: %(cell_value)s") % {
'row': rowx,
'col': colx,
- 'cell_value': xlrd.error_text_from_code.get(cell.value, _("unknown error code %s") % cell.value)
+ 'cell_value': xlrd.error_text_from_code.get(cell.value, _("unknown error code %s", cell.value))
}
)
else:
@@ -856,13 +856,13 @@ class Import(models.TransientModel):
response.raise_for_status()
if response.headers.get('Content-Length') and int(response.headers['Content-Length']) > maxsize:
- raise ValueError(_("File size exceeds configured maximum (%s bytes)") % maxsize)
+ raise ValueError(_("File size exceeds configured maximum (%s bytes)", maxsize))
content = bytearray()
for chunk in response.iter_content(DEFAULT_IMAGE_CHUNK_SIZE):
content += chunk
if len(content) > maxsize:
- raise ValueError(_("File size exceeds configured maximum (%s bytes)") % maxsize)
+ raise ValueError(_("File size exceeds configured maximum (%s bytes)", maxsize))
image = Image.open(io.BytesIO(content))
w, h = image.size