odoo_translate_html
Translate Odoo html_translate fields by extracting translatable terms, mapping translations directly, or replacing full HTML. Supports blog posts, product descriptions, and website content.
Instructions
Write/read translations for translate=html_translate / translate=xml_translate fields. Use for: blog.post.content, product.template.website_description, hr.job.description, ir.ui.view.arch_db (covers website.page), website.menu.mega_menu_content, event.track.description, forum.forum.guidelines, res.partner.website_description. Three modes: (a) mode='extract' — READ-ONLY. translations arg ignored. Returns the list of translatable terms that Odoo's html_translate engine extracts from source_lang. Each term is an HTML-serialised translatable block (preserves inline tags like ). Use this to see what must be translated before writing. (b) mode='terms' — translations = {lang: {source_term: translated_term, ...}} Direct term map. Terms must match exactly those from mode='extract'. Calls update_field_translations() with JSONB payload. (c) mode='replace' — translations = {lang: full_html_string}. The tool writes each language's HTML through Odoo's native ORM with {'lang': } context. Odoo's html_translate engine aligns terms automatically — no manual term extraction required. This is what Odoo's Website editor does internally. Errors if field.translate is not callable. Requires Odoo 16+.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connection | No | default | |
| model | Yes | ||
| res_id | Yes | ||
| field_name | Yes | ||
| translations | No | Either {lang: {term: translation}} (mode='terms') or {lang: 'full html'} (mode='replace'). Ignored for mode='extract'. | |
| mode | No | terms | |
| source_lang | No | en_US | |
| dry_run | No | ||
| mark_identical_as_translated | No | When True (default), terms whose target-lang value equals the source get prefixed with U+200B (zero-width-space) so Odoo stores them as explicit 'translated, kept identical' entries. Otherwise Odoo dedups them as 'untranslated', which flags technical terms (URLs, brand names, code) as needing translation in the website editor. |