Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _includes/js-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
or page.layout == 'category'
or page.layout == 'tag'
%}
{% assign locale = site.lang | split: '-' | first %}
{% assign locale = include.lang | split: '-' | first %}
neilboyd marked this conversation as resolved.
Show resolved Hide resolved

{% assign urls = urls
| append: ','
Expand Down
4 changes: 3 additions & 1 deletion _includes/lang.html
Original file line number Diff line number Diff line change
@@ -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' %}
cotes2020 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
4 changes: 2 additions & 2 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{% 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>
Expand Down Expand Up @@ -76,7 +76,7 @@

<!-- JavaScripts -->

{% include js-selector.html %}
{% include js-selector.html lang=lang %}
neilboyd marked this conversation as resolved.
Show resolved Hide resolved

{% if page.mermaid %}
{% include mermaid.html %}
Expand Down
Loading