Contributors mailing list archives

contributors@odoo-community.org

Browse archives

Avatar

Re: New Odoo17 translated fields

by
Tecnativa. S. L., David Vidal
- 01/02/2024 13:02:27
The ORM does it for you. Simply use the `lang` context:

```python
record.with_context(lang='es_ES`).field_name = translated_string
```

You can get your active languages with `self.env['res.lang'].get_installed()` and loop over them if you want to do it at once.

El jue, 1 feb 2024 a las 12:52, Johan Van Hirtum (<notifications@odoo-community.org>) escribió:

Dears,

 

Knows someone good developer documentation around the new translated fields in Odoo17 ? That there are stored in de database as jsonB field is clear. But I see nowhere how to set de translated terms for a field in a python method ( an on change or depends structure for ex. ). There must normally be a some variables where the translation are stored till the create method creates the model ? But I see nothing there.

I want to use a python translation package ( deepL, deep-translator ) to give a first translation automatically when the translatable field is typed in the ID. Users can adapt, if they want to, but mostly, these translation are simply good -)

 

Thanks for helping me out.

 

With kind regards,

 

 

Van Hirtum Johan

_______________________________________________
Mailing-List: https://odoo-community.org/groups/contributors-15
Post to: mailto:contributors@odoo-community.org
Unsubscribe: https://odoo-community.org/groups?unsubscribe

Reference