Skip to content

Commit 355bfa7

Browse files
0b11001111mart-e
authored andcommitted
[IMP] developer: extend internationalization guide
In order for javascript translations to become active, the corresponding addon needs to follow a certain naming scheme or register explicitly. This commit updates the internationalization guide with a respective hint. Fixes #1676 closes #1724 X-original-commit: 112b6c1 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
1 parent 943251b commit 355bfa7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

content/developer/misc/i18n/translations.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,26 @@ The lazy version of `_` and `_t` is :func:`odoo._lt` in python and
9797
at rendering and can be used to declare translatable properties in class methods
9898
of global variables.
9999

100+
.. note::
101+
102+
Translations of a module are **not** exposed to the front end by default and
103+
thus are not accessible from JavaScript. In order to achieve that, the
104+
module name has to be either prefixed with `website` (just like
105+
`website_sale`, `website_event` etc.) or explicitly register by implementing
106+
:func:`_get_translation_frontend_modules_name` for the `ir.http` model.
107+
108+
This could look like the following::
109+
110+
from odoo import models
111+
112+
class IrHttp(models.AbstractModel):
113+
_inherit = 'ir.http'
114+
115+
@classmethod
116+
def _get_translation_frontend_modules_name(cls):
117+
modules = super()._get_translation_frontend_modules_name()
118+
return modules + ['your_module']
119+
100120
Variables
101121
^^^^^^^^^
102122
**Don't** the extract may work but it will not translate the text correctly::

0 commit comments

Comments
 (0)