summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odoo/addons/test_translation_import/tests/test_term_count.py4
-rw-r--r--odoo/tools/translate.py16
2 files changed, 20 insertions, 0 deletions
diff --git a/odoo/addons/test_translation_import/tests/test_term_count.py b/odoo/addons/test_translation_import/tests/test_term_count.py
index ce23a1b899d..38f1e7a75fa 100644
--- a/odoo/addons/test_translation_import/tests/test_term_count.py
+++ b/odoo/addons/test_translation_import/tests/test_term_count.py
@@ -205,6 +205,10 @@ class TestTermCount(common.TransactionCase):
context = {'lang': "tlh"}
self.assertEqual(str(TRANSLATED_TERM), "tlhIngan", "The lazy code translation was not applied")
+ self.assertEqual("Do you speak " + TRANSLATED_TERM, "Do you speak tlhIngan", "str + _lt concatenation failed")
+ self.assertEqual(TRANSLATED_TERM + ", I speak it", "tlhIngan, I speak it", "_lt + str concatenation failed")
+ self.assertEqual(TRANSLATED_TERM + TRANSLATED_TERM, "tlhIngantlhIngan", "_lt + _lt concatenation failed")
+
def test_import_from_csv_file(self):
"""Test the import from a single CSV file works"""
with file_open('test_translation_import/i18n/dot.csv', 'rb') as f:
diff --git a/odoo/tools/translate.py b/odoo/tools/translate.py
index bb7f9fcea4b..eed29f7f784 100644
--- a/odoo/tools/translate.py
+++ b/odoo/tools/translate.py
@@ -539,6 +539,22 @@ class _lt:
def __lt__(self, other):
raise NotImplementedError()
+ def __add__(self, other):
+ # Call _._get_translation() like _() does, so that we have the same number
+ # of stack frames calling _get_translation()
+ if isinstance(other, str):
+ return _._get_translation(self._source) + other
+ elif isinstance(other, _lt):
+ return _._get_translation(self._source) + _._get_translation(other._source)
+ return NotImplemented
+
+ def __radd__(self, other):
+ # Call _._get_translation() like _() does, so that we have the same number
+ # of stack frames calling _get_translation()
+ if isinstance(other, str):
+ return other + _._get_translation(self._source)
+ return NotImplemented
+
_ = GettextAlias()