diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2019-05-27 08:03:55 +0000 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2019-05-27 09:11:25 +0000 |
| commit | c868da4de607d48d27d5cf9852871ed4698627f8 (patch) | |
| tree | fd20a8b82038082df9036c686953cef133c89d66 | |
| parent | ccdaf9a08572886f152ec929296765a0bb649acd (diff) | |
[FIX] tools: export UTF-8 characters
- Install Babel 2.3.4 as specified in the `requirements.txt`
- In a Python file, do not add the line `# -*- coding: utf-8 -*-`
- Create a translatable string with a non-ASCII character, e.g.
`Amount in €`
- Export the translation
The exported term is incorrect: `Amount in â¬`.
Since the default encoding for Python 3 is UTF-8, it is logical for the
Babel extraction to use it as a default encoding.
The issue was solved in Babel 2.4.0 with commit:
https://github.com/python-babel/babel/commit/33a8fc40d417b401162e2d20021fcbebcc4ab7db
opw-1984480
closes odoo/odoo#33671
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
| -rw-r--r-- | odoo/tools/translate.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/odoo/tools/translate.py b/odoo/tools/translate.py index 5561aa082c7..5a11f004ada 100644 --- a/odoo/tools/translate.py +++ b/odoo/tools/translate.py @@ -953,8 +953,11 @@ def trans_generate(lang, modules, cr): extra_comments = extra_comments or [] if not module: return src_file = open(fabsolutepath, 'rb') + options = {} + if extract_method == 'python': + options['encoding'] = 'UTF-8' try: - for extracted in extract.extract(extract_method, src_file, keywords=extract_keywords): + for extracted in extract.extract(extract_method, src_file, keywords=extract_keywords, options=options): # Babel 0.9.6 yields lineno, message, comments # Babel 1.3 yields lineno, message, comments, context lineno, message, comments = extracted[:3] |
