[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>
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user