Skip to content

Commit bd8ff4c

Browse files
committed
[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]: odoo/odoo@9bd60ca Remark: This commit also sets the `o_translate_inline` class by default on paragraph links in website templates. opw-3984439 closes #1055 Related: odoo/odoo#204453 Signed-off-by: Outagant Mehdi (mou) <[email protected]>
1 parent 8eaa7e9 commit bd8ff4c

File tree

19 files changed

+32
-32
lines changed

19 files changed

+32
-32
lines changed

theme_artists/views/snippets/s_carousel.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<h2 style="text-align: center;">Aquitani</h2>
99
<p class="lead" style="text-align: center;"><b>Photoshoot / June 2021</b></p>
1010
<p style="text-align: center;">
11-
<a href="#" class="btn btn-primary btn-lg">Discover</a>
11+
<a href="#" class="btn btn-primary btn-lg o_translate_inline">Discover</a>
1212
</p>
1313
</div>
1414
</xpath>
@@ -27,7 +27,7 @@
2727
<h2 style="text-align: center;">Immemorabili</h2>
2828
<p class="lead" style="text-align: center;"><b>Painting concept / April 2021</b></p>
2929
<p style="text-align: center;">
30-
<a href="#" class="btn btn-primary btn-lg">Discover</a>
30+
<a href="#" class="btn btn-primary btn-lg o_translate_inline">Discover</a>
3131
</p>
3232
</div>
3333
</xpath>
@@ -46,7 +46,7 @@
4646
<h2 style="text-align: center;">Vincam</h2>
4747
<p class="lead" style="text-align: center;"><b>Typographic collection / March 2021</b></p>
4848
<p style="text-align: center;">
49-
<a href="#" class="btn btn-primary btn-lg">Discover</a>
49+
<a href="#" class="btn btn-primary btn-lg o_translate_inline">Discover</a>
5050
</p>
5151
</div>
5252
</xpath>

theme_artists/views/snippets/s_three_columns.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</xpath>
2525
<!-- Column #1 - Add a button -->
2626
<xpath expr="//div[hasclass('card-body')]//p" position="after">
27-
<p><a href="#" class="btn btn-primary">More details</a></p>
27+
<p><a href="#" class="btn btn-primary o_translate_inline">More details</a></p>
2828
</xpath>
2929
<!-- Column #2 -->
3030
<xpath expr="(//div[hasclass('card')])[2]" position="attributes">
@@ -44,7 +44,7 @@
4444
</xpath>
4545
<!-- Column #2 - Add a button -->
4646
<xpath expr="(//div[hasclass('card-body')])[2]//p" position="after">
47-
<p><a href="#" class="btn btn-primary">Discover</a></p>
47+
<p><a href="#" class="btn btn-primary o_translate_inline">Discover</a></p>
4848
</xpath>
4949
<!-- Column #3 -->
5050
<xpath expr="(//div[hasclass('card')])[3]" position="attributes">
@@ -64,7 +64,7 @@
6464
</xpath>
6565
<!-- Column #3 - Add a button -->
6666
<xpath expr="(//div[hasclass('card-body')])[3]//p" position="after">
67-
<p><a href="/contactus" class="btn btn-primary">Contact me</a></p>
67+
<p><a href="/contactus" class="btn btn-primary o_translate_inline">Contact me</a></p>
6868
</xpath>
6969
</template>
7070

theme_cobalt/views/customizations.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
<h5>Web &amp; App Development</h5>
9292
<p>We have collected solid experience in building native and cross-platform mobile applications and websites. Check our portfolio from clients around the world.</p>
9393
<br/>
94-
<p><a href="#" class="btn btn-secondary">Learn more</a></p>
94+
<p><a href="#" class="btn btn-secondary o_translate_inline">Learn more</a></p>
9595
</xpath>
9696
<xpath expr="//a[hasclass('btn')]" position="replace"/>
9797
</template>

theme_enark/views/snippets/s_numbers_list.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<template id="s_numbers_list" inherit_id="website.s_numbers_list">
55
<xpath expr="//div[hasclass('col-lg-5')]//p" position="after">
66
<p><br/></p>
7-
<p><a href="#" class="btn btn-secondary">More details</a></p>
7+
<p><a href="#" class="btn btn-secondary o_translate_inline">More details</a></p>
88
</xpath>
99
</template>
1010

theme_graphene/views/customizations.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Our mission is to give customers the best experience.<br/>Extensive documentation &amp; guides, an active community,<br/>24/7 support make it a pleasure to work with us.
2323
</p>
2424
<p>
25-
<a t-att-href="cta_btn_href" class="btn btn-primary btn-lg"><t t-esc="cta_btn_text">Contact us</t></a>
25+
<a t-att-href="cta_btn_href" class="btn btn-primary btn-lg o_translate_inline"><t t-esc="cta_btn_text">Contact us</t></a>
2626
</p>
2727
</div>
2828
</div>

theme_kea/views/snippets/s_cover.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<!-- Button -->
2626
<xpath expr="//a[hasclass('btn')]" position="replace"/>
2727
<xpath expr="//a[hasclass('btn')]" position="replace">
28-
<a href="#0" class="btn btn-primary btn-lg">Discover more</a>
28+
<a href="#0" class="btn btn-primary btn-lg o_translate_inline">Discover more</a>
2929
</xpath>
3030
</template>
3131

theme_kiddo/views/snippets/s_call_to_action.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<h3 style="text-align: center;">2,000 parents<br/> brought their kid to our nursery.</h3>
2020
<p style="text-align: center;">Entrust us with your children and go to work with peace of mind</p>
2121
<p><br/></p>
22-
<p style="text-align: center;"><a t-att-href="cta_btn_href" class="btn btn-primary btn-lg"><t t-esc="cta_btn_text">Contact us</t></a></p>
22+
<p style="text-align: center;"><a t-att-href="cta_btn_href" class="btn btn-primary btn-lg o_translate_inline"><t t-esc="cta_btn_text">Contact us</t></a></p>
2323
</div>
2424
</xpath>
2525

theme_loftspace/views/snippets/s_call_to_action.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</xpath>
2828
<!-- Add secondary button -->
2929
<xpath expr="//a[hasclass('btn')]" position="before">
30-
<a href="#" class="btn btn-secondary btn-lg me-2 mb-2">Our services</a>
30+
<a href="#" class="btn btn-secondary btn-lg me-2 mb-2 o_translate_inline">Our services</a>
3131
</xpath>
3232
</template>
3333

theme_monglia/views/customizations.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
</xpath>
182182
<xpath expr="//p[2]" position="replace"/>
183183
<xpath expr="//a" position="replace">
184-
<a href="/contactus" class="btn btn-primary">Learn more</a>
184+
<a href="/contactus" class="btn btn-primary o_translate_inline">Learn more</a>
185185
</xpath>
186186
</template>
187187

@@ -227,7 +227,7 @@
227227
<p class="lead">This is the first full-length studio release in seven years for the British singer-songwriter.</p>
228228
</xpath>
229229
<xpath expr="//a" position="replace">
230-
<a href="/contactus" class="btn btn-primary">Discover</a>
230+
<a href="/contactus" class="btn btn-primary o_translate_inline">Discover</a>
231231
</xpath>
232232
<xpath expr="(//div[hasclass('carousel-item')])[2]" position="attributes">
233233
<attribute name="class" add="o_cc o_cc5" separator=" "/>

theme_nano/views/snippets/s_discovery.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</xpath>
2222

2323
<xpath expr="//p[2]" position="replace" mode="inner">
24-
<a t-att-href="cta_btn_href" class="btn btn-lg btn-primary"><t t-out="cta_btn_text">Get Started</t></a>
24+
<a t-att-href="cta_btn_href" class="btn btn-lg btn-primary o_translate_inline"><t t-out="cta_btn_text">Get Started</t></a>
2525
</xpath>
2626

2727
</template>

0 commit comments

Comments
 (0)