feat(i18n): allow page.lang
to override site.lang
(#1586)
This commit is contained in:
parent
2a7b56bb36
commit
547b95cc7a
3 changed files with 6 additions and 4 deletions
|
@ -33,7 +33,7 @@
|
||||||
or page.layout == 'category'
|
or page.layout == 'category'
|
||||||
or page.layout == 'tag'
|
or page.layout == 'tag'
|
||||||
%}
|
%}
|
||||||
{% assign locale = site.lang | split: '-' | first %}
|
{% assign locale = include.lang | split: '-' | first %}
|
||||||
|
|
||||||
{% assign urls = urls
|
{% assign urls = urls
|
||||||
| append: ','
|
| append: ','
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
{% comment %}
|
{% comment %}
|
||||||
Detect appearance language and return it through variable "lang"
|
Detect appearance language and return it through variable "lang"
|
||||||
{% endcomment %}
|
{% 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 %}
|
{% assign lang = site.lang %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% assign lang = 'en' %}
|
{% assign lang = 'en' %}
|
||||||
|
|
|
@ -13,7 +13,7 @@ layout: compress
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<!-- `site.alt_lang` can specify a language different from the UI -->
|
<!-- `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 %}
|
{% include head.html %}
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -76,7 +76,7 @@ layout: compress
|
||||||
|
|
||||||
<!-- JavaScripts -->
|
<!-- JavaScripts -->
|
||||||
|
|
||||||
{% include js-selector.html %}
|
{% include js-selector.html lang=lang %}
|
||||||
|
|
||||||
{% if page.mermaid %}
|
{% if page.mermaid %}
|
||||||
{% include mermaid.html %}
|
{% include mermaid.html %}
|
||||||
|
|
Loading…
Reference in a new issue