diff --git a/web_html_field_translate_dialog/README.rst b/web_html_field_translate_dialog/README.rst new file mode 100644 index 000000000000..a37061b63d4b --- /dev/null +++ b/web_html_field_translate_dialog/README.rst @@ -0,0 +1,100 @@ +.. image:: https://odoo-community.org/readme-banner-image + :target: https://odoo-community.org/get-involved?utm_source=readme + :alt: Odoo Community Association + +=============================== +Web HTML Field Translate Dialog +=============================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:5a13aaec2fb305abd1c814fdaf78669366e648119b3e025a37fc47ebc2a5b682 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github + :target: https://github.com/OCA/web/tree/19.0/web_html_field_translate_dialog + :alt: OCA/web +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/web-19-0/web-19-0-web_html_field_translate_dialog + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=19.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module improves the usability of translating **HTML** fields. + +The standard translation dialog of an HTML field splits its content into +individual source terms (chunks) and asks the user to translate each one +separately. This is technical and hard to use for end users, especially +on rich content. + +With this module, the translation button next to an HTML field opens a +dialog that shows one **full rich-text editor per installed language**. +The user reads and edits the whole translation of each language as a +single block, exactly as the field is edited in the form. + +Each language can be toggled between the rich-text editor and a raw +**HTML source** ("technical") view, so content the editor cannot handle +safely can still be translated. Values that contain markup the editor +cannot round-trip (full documents, `` + + +
+ + + +Odoo Community Association + +
+

Web HTML Field Translate Dialog

+ +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

This module improves the usability of translating HTML fields.

+

The standard translation dialog of an HTML field splits its content into +individual source terms (chunks) and asks the user to translate each one +separately. This is technical and hard to use for end users, especially +on rich content.

+

With this module, the translation button next to an HTML field opens a +dialog that shows one full rich-text editor per installed language. +The user reads and edits the whole translation of each language as a +single block, exactly as the field is edited in the form.

+

Each language can be toggled between the rich-text editor and a raw +HTML source (“technical”) view, so content the editor cannot handle +safely can still be translated. Values that contain markup the editor +cannot round-trip (full documents, <style> blocks or QWeb directives +such as those found in email templates) open in the HTML source view by +default.

+

The standard term-by-term dialog is kept untouched for char and +text translatable fields.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • ForgeFlow
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

This module is part of the OCA/web project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+
+ + diff --git a/web_html_field_translate_dialog/static/src/html_translation_dialog/html_translation_dialog.esm.js b/web_html_field_translate_dialog/static/src/html_translation_dialog/html_translation_dialog.esm.js new file mode 100644 index 000000000000..52e96af0c862 --- /dev/null +++ b/web_html_field_translate_dialog/static/src/html_translation_dialog/html_translation_dialog.esm.js @@ -0,0 +1,172 @@ +/* Copyright 2025 ForgeFlow S.L. + * License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). */ + +import {Component, markup, onWillStart, useState} from "@odoo/owl"; +import {Dialog} from "@web/core/dialog/dialog"; +import { + MAIN_PLUGINS, + NO_EMBEDDED_COMPONENTS_FALLBACK_PLUGINS, +} from "@html_editor/plugin_sets"; +import {Wysiwyg} from "@html_editor/wysiwyg"; +import {_t, loadLanguages} from "@web/core/l10n/translation"; +import {useService} from "@web/core/utils/hooks"; +import {user} from "@web/core/user"; + +/** + * Return true when the value contains markup the rich-text editor cannot + * round-trip safely (full/partial documents,