Skip to content

Commit cdc39b2

Browse files
committed
部分支持优先使用 page.locale
1 parent c749b2a commit cdc39b2

File tree

9 files changed

+29
-21
lines changed

9 files changed

+29
-21
lines changed

_includes/footer.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
{% assign locale = include.locale | default: page.locale | default: site.locale %}
12
{% unless site.atom_feed.hide %}
23
{% assign show_atom = true %}
34
{% endunless %}
45
{% if site.footer.links or show_atom %}
56
<div class="page__footer-follow">
67
<ul class="social-icons">
7-
{% if site.data.ui-text[site.locale].follow_label %}
8-
<li><strong>{{ site.data.ui-text[site.locale].follow_label }}</strong></li>
8+
{% if site.data.ui-text[locale].follow_label %}
9+
<li><strong>{{ site.data.ui-text[locale].follow_label }}</strong></li>
910
{% endif %}
1011

1112
{% if site.footer.links %}
@@ -17,10 +18,10 @@
1718
{% endif %}
1819

1920
{% unless site.atom_feed.hide %}
20-
<li><a href="{% if site.atom_feed.path %}{{ site.atom_feed.path }}{% else %}{{ '/feed.xml' | relative_url }}{% endif %}"><i class="fas fa-fw fa-rss-square" aria-hidden="true"></i> {{ site.data.ui-text[site.locale].feed_label | default: "Feed" }}</a></li>
21+
<li><a href="{% if site.atom_feed.path %}{{ site.atom_feed.path }}{% else %}{{ '/feed.xml' | relative_url }}{% endif %}"><i class="fas fa-fw fa-rss-square" aria-hidden="true"></i> {{ site.data.ui-text[locale].feed_label | default: "Feed" }}</a></li>
2122
{% endunless %}
2223
</ul>
2324
</div>
2425
{% endif %}
2526

26-
<div class="page__footer-copyright">&copy; {% assign site_time = site.time | date: '%Y' %}{% if site.footer.since and site_time != site.footer.since %}{{ site.footer.since }} - {% endif %}{{ site_time }} <a href="{{ site.copyright_url | default: site.url }}">{{ site.copyright | default: site.title | escape_once | strip }}</a>. {{ site.data.ui-text[site.locale].powered_by | default: "Powered by" }} <a href="https://jekyllrb.com" rel="nofollow">Jekyll</a> &amp; <a href="https://mademistakes.com/work/jekyll-themes/minimal-mistakes/" rel="nofollow">Minimal Mistakes</a>.</div>
27+
<div class="page__footer-copyright">&copy; {% assign site_time = site.time | date: '%Y' %}{% if site.footer.since and site_time != site.footer.since %}{{ site.footer.since }} - {% endif %}{{ site_time }} <a href="{{ site.copyright_url | default: site.url }}">{{ site.copyright | default: site.title | escape_once | strip }}</a>. {{ site.data.ui-text[locale].powered_by | default: "Powered by" }} <a href="https://jekyllrb.com" rel="nofollow">Jekyll</a> &amp; <a href="https://mademistakes.com/work/jekyll-themes/minimal-mistakes/" rel="nofollow">Minimal Mistakes</a>.</div>

_includes/nav_list

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
{% assign locale = page.locale | default: site.locale %}
12
<nav class="nav__list">
23
{% if page.sidebar.title %}<h3 class="nav__title" style="padding-left: 0;">{{ page.sidebar.title }}</h3>{% endif %}
34
<input id="ac-toc" name="accordion-toc" type="checkbox" />
4-
<label for="ac-toc">{{ site.data.ui-text[site.locale].menu_label | default: "Toggle Menu" }}</label>
5+
<label for="ac-toc">{{ site.data.ui-text[locale].menu_label | default: "Toggle Menu" }}</label>
56
<ul class="nav__items">
67
{% for navname in include.nav %}
78
{% assign navigation = site.data.navigation[navname] %}

_includes/page__date.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
{% assign locale = page.locale | default: site.locale %}
12
{% assign date_format = site.date_format | default: "%B %-d, %Y" %}
23
{% if page.last_modified_at %}
3-
<p class="page__date"><strong><i class="fas fa-fw fa-calendar-alt" aria-hidden="true"></i> {{ site.data.ui-text[site.locale].date_label | default: "Updated:" }}</strong> <time class="dt-published" datetime="{{ page.last_modified_at | date: "%Y-%m-%d" }}">{{ page.last_modified_at | date: date_format }}</time></p>
4+
<p class="page__date"><strong><i class="fas fa-fw fa-calendar-alt" aria-hidden="true"></i> {{ site.data.ui-text[locale].date_label | default: "Updated:" }}</strong> <time class="dt-published" datetime="{{ page.last_modified_at | date: "%Y-%m-%d" }}">{{ page.last_modified_at | date: date_format }}</time></p>
45
{% elsif page.date %}
5-
<p class="page__date"><strong><i class="fas fa-fw fa-calendar-alt" aria-hidden="true"></i> {{ site.data.ui-text[site.locale].date_label | default: "Updated:" }}</strong> <time class="dt-published" datetime="{{ page.date | date_to_xmlschema }}">{{ page.date | date: date_format }}</time></p>
6+
<p class="page__date"><strong><i class="fas fa-fw fa-calendar-alt" aria-hidden="true"></i> {{ site.data.ui-text[locale].date_label | default: "Updated:" }}</strong> <time class="dt-published" datetime="{{ page.date | date_to_xmlschema }}">{{ page.date | date: date_format }}</time></p>
67
{% endif %}

_includes/post_pagination.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
{% assign locale = page.locale | default: site.locale %}
12
{% if page.previous or page.next %}
23
<nav class="pagination">
34
{% if page.previous %}
4-
<a href="{{ page.previous.url | relative_url }}" class="pagination--pager" title="{{ page.previous.title | markdownify | strip_html | strip}}">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a>
5+
<a href="{{ page.previous.url | relative_url }}" class="pagination--pager" title="{{ page.previous.title | markdownify | strip_html | strip}}">{{ site.data.ui-text[locale].pagination_previous | default: "Previous" }}</a>
56
{% else %}
6-
<a href="#" class="pagination--pager disabled">{{ site.data.ui-text[site.locale].pagination_previous | default: "Previous" }}</a>
7+
<a href="#" class="pagination--pager disabled">{{ site.data.ui-text[locale].pagination_previous | default: "Previous" }}</a>
78
{% endif %}
89
{% if page.next %}
9-
<a href="{{ page.next.url | relative_url }}" class="pagination--pager" title="{{ page.next.title | markdownify | strip_html | strip}}">{{ site.data.ui-text[site.locale].pagination_next | default: "Next" }}</a>
10+
<a href="{{ page.next.url | relative_url }}" class="pagination--pager" title="{{ page.next.title | markdownify | strip_html | strip}}">{{ site.data.ui-text[locale].pagination_next | default: "Next" }}</a>
1011
{% else %}
11-
<a href="#" class="pagination--pager disabled">{{ site.data.ui-text[site.locale].pagination_next | default: "Next" }}</a>
12+
<a href="#" class="pagination--pager disabled">{{ site.data.ui-text[locale].pagination_next | default: "Next" }}</a>
1213
{% endif %}
1314
</nav>
1415
{% endif %}

_includes/search/lunr-search-scripts.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{% assign lang = site.locale | slice: 0,2 | default: "en" %}
1+
{% assign locale = page.locale | default: site.locale %}
2+
{% assign lang = locale | slice: 0,2 | default: "en" %}
23
{% case lang %}
34
{% when "gr" %}
45
{% assign lang = "gr" %}

_includes/seo.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!-- begin _includes/seo.html -->
2+
{%- assign locale = page.locale | default: site.locale -%}
23
{%- assign title_separator = site.title_separator | default: '-' -%}
34

45
{%- assign page_title = page.title | default: site.title | replace: '|', '&#124;' -%}
@@ -35,7 +36,7 @@
3536
{%- assign og_type = "website" -%}
3637
{%- endif -%}
3738

38-
<title>{{ seo_title }}{% if paginator %}{% unless paginator.page == 1 %} {{ title_separator }} {{ site.data.ui-text[site.locale].page | default: "Page" }} {{ paginator.page }}{% endunless %}{% endif %}</title>
39+
<title>{{ seo_title }}{% if paginator %}{% unless paginator.page == 1 %} {{ title_separator }} {{ site.data.ui-text[locale].page | default: "Page" }} {{ paginator.page }}{% endunless %}{% endif %}</title>
3940
<meta name="description" content="{{ seo_description }}">
4041

4142
{% if author.name %}
@@ -46,7 +47,7 @@
4647
{% endif %}
4748

4849
<meta property="og:type" content="{{ og_type }}">
49-
<meta property="og:locale" content="{{ site.locale | replace: "-", "_" | default: "en_US" }}">
50+
<meta property="og:locale" content="{{ locale | replace: '-', '_' | default: 'en_US' }}">
5051
<meta property="og:site_name" content="{{ site.title | escape_once | strip }}">
5152
<meta property="og:title" content="{{ page_title }}">
5253
<meta property="og:url" content="{{ canonical_url }}">

_layouts/default.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
---
22
layout: compress
33
---
4+
{%- assign locale = page.locale | default: site.locale %}
45

56
<!doctype html>
67
{% include copyright.html %}
7-
<html lang="{{ site.locale | replace: "_", "-" | default: "en" }}" class="no-js">
8+
<html lang="{{ locale | default: 'en' }}" class="no-js">
89
<head>
910
{% include head.html %}
1011
{% include head/custom.html %}
@@ -32,7 +33,7 @@
3233
<div id="footer" class="page__footer">
3334
<footer>
3435
{% include footer/custom.html %}
35-
{% include_cached footer.html %}
36+
{% include_cached footer.html locale=locale %}
3637
</footer>
3738
</div>
3839

_layouts/document.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<img src="https://hits.zkitefly.eu.org/?tag={{ page.url | absolute_url | url_encode }}" alt="Hits" decoding="async">
77
{% endif %}
88

9-
{% if page.origin_lang and page.lang and page.origin_lang != page.lang %}
9+
{% if page.origin_locale and page.locale and page.origin_locale != page.locale %}
1010
<div class="notice--warning">当前页面语言与实际语言不一致</div>
1111
{% endif %}
1212

_layouts/single.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
layout: default
33
---
4+
{%- assign locale = page.locale | default: site.locale %}
45

56
{% if page.header.overlay_color or page.header.overlay_image or page.header.image %}
67
{% include page__hero.html %}
@@ -43,18 +44,18 @@ <h1 id="page-title" class="page__title" itemprop="headline">
4344
{% if page.toc %}
4445
<aside class="sidebar__right {% if page.toc_sticky %}sticky{% endif %}">
4546
<nav class="toc">
46-
<header><h4 class="nav__title"><i class="fas fa-{{ page.toc_icon | default: 'file-alt' }}"></i> {{ page.toc_label | default: site.data.ui-text[site.locale].toc_label | default: "On this page" }}</h4></header>
47+
<header><h4 class="nav__title"><i class="fas fa-{{ page.toc_icon | default: 'file-alt' }}"></i> {{ page.toc_label | default: site.data.ui-text[locale].toc_label | default: "On this page" }}</h4></header>
4748
{% include toc.html sanitize=true html=content h_min=1 h_max=6 class="toc__menu" skip_no_ids=true %}
4849
</nav>
4950
</aside>
5051
{% endif %}
5152
{{ content }}
52-
{% if page.link %}<div><a href="{{ page.link }}" class="btn btn--primary">{{ site.data.ui-text[site.locale].ext_link_label | default: "Direct Link" }}</a></div>{% endif %}
53+
{% if page.link %}<div><a href="{{ page.link }}" class="btn btn--primary">{{ site.data.ui-text[locale].ext_link_label | default: "Direct Link" }}</a></div>{% endif %}
5354
</section>
5455

5556
<footer class="page__meta">
56-
{% if site.data.ui-text[site.locale].meta_label %}
57-
<h4 class="page__meta-title">{{ site.data.ui-text[site.locale].meta_label }}</h4>
57+
{% if site.data.ui-text[locale].meta_label %}
58+
<h4 class="page__meta-title">{{ site.data.ui-text[locale].meta_label }}</h4>
5859
{% endif %}
5960
{% include page__taxonomy.html %}
6061
{% include page__date.html %}

0 commit comments

Comments
 (0)