Files
design-themes/theme_notes
Mehdi Outagant (MOU) bd8ff4cb1d [FIX] theme_*: translate paragraph links as a whole.
*: artists, cobalt, enark, graphene, kea, kiddo, loftspace, monglia, nano,
notes, odoo_experts, orchid, paptic, real_estate, vehicle, yes

Steps to reproduce:

1. Enable a second language in the website (e.g., French).

2. Add a "Text" block (in edit mode) > Save the page.

3. Translate a text paragraph to french > Save.

4. In edit mode again, add a link to a word in the paragraph > Save.

5. The translation in French is lost, and sometimes the whole French
    translation is used for the text before or after the link.

This is actually a limitation in the translation implementation. If we
initially have `text_1_en text_2_en text_3_en` translated to French this
way:

terms en_US: `["text_1_en text_2_en text_3_en"]`
terms fr_BE: `["text_1_fr text_2_fr text_3_fr"]`

After adding a link: `text_1_en<a...>text_2_en</a>text_3_en`, and since
the links are not translated as a whole, we should get:

terms en_US: `["text_1_en", "text_2_en", "text_3_en"]`
terms fr_BE: `["text_1_fr text_2_fr text_3_fr"]`

Which means the current translation will be lost, and the result will
depend on the outcome of `get_close_matches()`. Which explains why when
the link is added to the first words of the paragraph, the system still
maps the rest of the paragraph to its "full old translation".

The goal of this commit is to make this behavior less aggressive by
forcing the links added in paragraphs [1] to be translated as a whole.
This way, the `get_close_matches()` will map the new content with a link
to its old translation (without a link), and then, the user can set the
link in the "the most meaningful part of the translation" in the
translate mode.

[1]: We should use the "translate as a whole" feature carefully with
links, since there are already some situations where it's causing
issues (see the fix in [2]). So we only force them inside paragraphs.

[2]: https://github.com/odoo/odoo/commit/9bd60ca93510e410a0136b8b433f596330900593

Remark: This commit also sets the `o_translate_inline` class by default
on paragraph links in website templates.

opw-3984439

closes odoo/design-themes#1055

Related: odoo/odoo#204453
Signed-off-by: Outagant Mehdi (mou) <mou@odoo.com>
2025-04-14 09:28:47 +00:00
..
2025-02-24 18:31:04 +00:00
2021-05-10 15:45:35 +02:00