feat(i18n): allow page.lang to override site.lang (#1586)

This commit is contained in:
Neil Boyd 2024-03-04 20:09:39 +01:00 committed by GitHub
parent 2a7b56bb36
commit 547b95cc7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 4 deletions

View file

@ -33,7 +33,7 @@
or page.layout == 'category'
or page.layout == 'tag'
%}
{% assign locale = site.lang | split: '-' | first %}
{% assign locale = include.lang | split: '-' | first %}
{% assign urls = urls
| append: ','

View file

@ -1,7 +1,9 @@
{% comment %}
Detect appearance language and return it through variable "lang"
{% endcomment %}
{% if site.data.locales[site.lang] %}
{% if site.data.locales[page.lang] %}
{% assign lang = page.lang %}
{% elsif site.data.locales[site.lang] %}
{% assign lang = site.lang %}
{% else %}
{% assign lang = 'en' %}

View file

@ -13,7 +13,7 @@ layout: compress
{% endif %}
<!-- `site.alt_lang` can specify a language different from the UI -->
<html lang="{{ site.alt_lang | default: site.lang }}" {{ prefer_mode }}>
<html lang="{{ page.lang | default: site.alt_lang | default: site.lang }}" {{ prefer_mode }}>
{% include head.html %}
<body>
@ -76,7 +76,7 @@ layout: compress
<!-- JavaScripts -->
{% include js-selector.html %}
{% include js-selector.html lang=lang %}
{% if page.mermaid %}
{% include mermaid.html %}