Skip to content

Commit e0894e3

Browse files
committed
[IMP] conf: special case alt lang links for legal terms
Legal terms live under specific URL as their translations are not managed in the same manner. Layout is like this: /terms/enterprise.html (EN) /terms/i18n/enterprise_fr.html (FR) This commit adapts the generation of alternative languages links for each "legal terms page", so that it targets the correct i18n link, or goes back to the canonical EN one, depending on the target language. closes #7382 closes #7384 closes #7387 Signed-off-by: Olivier Dony (odo) <odo@odoo.com>
1 parent 0c4dde0 commit e0894e3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

conf.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,24 @@ def _build_url(_version=None, _lang=None):
478478
_version = _version or app.config.version
479479
_lang = _lang or app.config.language or 'en'
480480
_canonical_page = f'{pagename}.html'
481+
482+
# legal translations have different URLs schemes as they are not managed on transifex
483+
# e.g. FR translation of /terms/enterprise => /fr/terms/enterprise_fr
484+
if pagename.startswith('legal/terms/'):
485+
if _lang in legal_translations and not pagename.endswith(f"_{_lang}"):
486+
# remove language code for current translation, set target one
487+
_page = re.sub("_[a-z]{2}$", "", pagename)
488+
if 'terms/i18n' not in _page:
489+
_page = _page.replace("/terms/", "/terms/i18n/")
490+
_canonical_page = f'{_page}_{_lang}.html'
491+
elif _lang == 'en' and pagename.endswith(tuple(f"_{l}" for l in legal_translations)):
492+
# remove language code for current translation, link to original EN one
493+
_page = re.sub("_[a-z]{2}$", "", pagename)
494+
_canonical_page = f'{_page.replace("/i18n/", "/")}.html'
495+
481496
if app.config.is_remote_build:
482497
_canonical_page = _canonical_page.replace('index.html', '')
498+
483499
return f'{_root}' \
484500
f'{f"/{_version}" if app.config.versions else ""}' \
485501
f'{f"/{_lang}" if _lang != "en" else ""}' \

extensions/odoo_theme/layout_templates/legal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ <h5 class="card-title mb-0 d-flex flex-wrap gap-2">{{ _("Odoo Enterprise Agreeme
4040
<a class="btn btn-primary" href="{{ enterprise_agreement_path_en }}" role="button">{{ _("Read") }}</a>
4141
{%- else %}
4242
<a class="btn btn-primary" href="{{ 'legal/terms/i18n/enterprise_%s.html' % language_code }}" role="button">{{ _("Read") }}</a>
43-
<a class="btn btn-light text-primary" href="{{ enterprise_agreement_path_en }}">{{ _("English") }}</a>
43+
<a class="btn btn-light text-primary" href="../{{ enterprise_agreement_path_en }}">{{ _("English") }}</a>
4444
{%- endif %}
4545
</div>
4646
</div>

0 commit comments

Comments
 (0)