1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-18 05:41:31 +00:00

perf(i18n): set the global default locales to "en" (#979)

Avoid missing labels caused by languages ​​outside of locales.
This commit is contained in:
Cotes Chung
2023-05-06 07:22:29 +08:00
parent aca79c1007
commit 61fdbcb83a
23 changed files with 417 additions and 342 deletions

View File

@@ -3,8 +3,10 @@ layout: page
# The Archives of posts.
---
{% assign df_strftime_m = site.data.locales[site.lang].df.archives.strftime | default: '/ %m' %}
{% assign df_dayjs_m = site.data.locales[site.lang].df.archives.dayjs | default: '/ MM' %}
{% include lang.html %}
{% assign df_strftime_m = site.data.locales[lang].df.archives.strftime | default: '/ %m' %}
{% assign df_dayjs_m = site.data.locales[lang].df.archives.dayjs | default: '/ MM' %}
<div id="archives" class="pl-xl-3">

View File

@@ -3,8 +3,10 @@ layout: page
# All the Categories of posts
---
{% assign HEAD_PREFIX = "h_" %}
{% assign LIST_PREFIX = "l_" %}
{% include lang.html %}
{% assign HEAD_PREFIX = 'h_' %}
{% assign LIST_PREFIX = 'l_' %}
{% assign group_index = 0 %}
@@ -16,7 +18,7 @@ layout: page
{% assign first_post = posts_of_category | first %}
{% if category_name == first_post.categories[0] %}
{% assign sub_categories = "" | split: "" %}
{% assign sub_categories = '' | split: '' %}
{% for post in posts_of_category %}
{% assign second_category = post.categories[1] %}
@@ -30,89 +32,107 @@ layout: page
{% assign sub_categories = sub_categories | sort %}
{% assign sub_categories_size = sub_categories | size %}
<div class="card categories">
<!-- top-category -->
<div id="{{ HEAD_PREFIX }}{{ group_index }}"
class="card-header d-flex justify-content-between hide-border-bottom">
<span>
<i class="far fa-folder{% if sub_categories_size > 0 %}-open{% endif %} fa-fw"></i>
<div class="card categories">
<!-- top-category -->
<div
id="{{ HEAD_PREFIX }}{{ group_index }}"
class="card-header d-flex justify-content-between hide-border-bottom"
>
<span>
<i class="far fa-folder{% if sub_categories_size > 0 %}-open{% endif %} fa-fw"></i>
{% capture _category_url %}/categories/{{ category_name | slugify | url_encode }}/{% endcapture %}
<a href="{{ _category_url | relative_url }}" class="ml-1 mr-2">{{ category_name }}</a>
{% capture _category_url %}/categories/{{ category_name | slugify | url_encode }}/{% endcapture %}
<a href="{{ _category_url | relative_url }}" class="ml-1 mr-2">{{ category_name }}</a>
<!-- content count -->
{% assign top_posts_size = site.categories[category_name] | size %}
<span class="text-muted small font-weight-light">
{% if sub_categories_size > 0 %}
{{ sub_categories_size }}
{% if sub_categories_size > 1 %}
{{ site.data.locales[site.lang].categories.category_measure.plural
| default: site.data.locales[site.lang].categories.category_measure }}
{% else %}
{{ site.data.locales[site.lang].categories.category_measure.singular
| default: site.data.locales[site.lang].categories.category_measure }}
{% endif %},
{% endif %}
{{ top_posts_size }}
{% if top_posts_size > 1 %}
{{ site.data.locales[site.lang].categories.post_measure.plural
| default: site.data.locales[site.lang].categories.post_measure }}
{% else %}
{{ site.data.locales[site.lang].categories.post_measure.singular
| default: site.data.locales[site.lang].categories.post_measure }}
{% endif %}
</span>
</span>
<!-- arrow -->
{% if sub_categories_size > 0%}
<a href="#{{ LIST_PREFIX }}{{ group_index }}" data-toggle="collapse"
aria-expanded="true" aria-label="{{ HEAD_PREFIX }}{{ group_index }}-trigger"
class="category-trigger hide-border-bottom">
<i class="fas fa-fw fa-angle-down"></i>
</a>
{% else %}
<span data-toggle="collapse" class="category-trigger hide-border-bottom disabled">
<i class="fas fa-fw fa-angle-right"></i>
</span>
{% endif %}
</div> <!-- .card-header -->
<!-- Sub-categories -->
{% if sub_categories_size > 0 %}
<div id="{{ LIST_PREFIX }}{{ group_index }}" class="collapse show" aria-expanded="true">
<ul class="list-group">
{% for sub_category in sub_categories %}
<li class="list-group-item">
<i class="far fa-folder fa-fw"></i>
{% capture _sub_ctg_url %}/categories/{{ sub_category | slugify | url_encode }}/{% endcapture %}
<a href="{{ _sub_ctg_url | relative_url }}" class="ml-1 mr-2">{{ sub_category }}</a>
{% assign posts_size = site.categories[sub_category] | size %}
<!-- content count -->
{% assign top_posts_size = site.categories[category_name] | size %}
<span class="text-muted small font-weight-light">
{{ posts_size }}
{% if sub_categories_size > 0 %}
{{ sub_categories_size }}
{% if sub_categories_size > 1 %}
{{
site.data.locales[lang].categories.category_measure.plural
| default: site.data.locales[lang].categories.category_measure
}}
{% else %}
{{
site.data.locales[lang].categories.category_measure.singular
| default: site.data.locales[lang].categories.category_measure
}}
{% endif -%}
,
{% endif %}
{% if posts_size > 1 %}
{{ site.data.locales[site.lang].categories.post_measure.plural
| default: site.data.locales[site.lang].categories.post_measure }}
{{ top_posts_size }}
{% if top_posts_size > 1 %}
{{
site.data.locales[lang].categories.post_measure.plural
| default: site.data.locales[lang].categories.post_measure
}}
{% else %}
{{ site.data.locales[site.lang].categories.post_measure.singular
| default: site.data.locales[site.lang].categories.post_measure }}
{{
site.data.locales[lang].categories.post_measure.singular
| default: site.data.locales[lang].categories.post_measure
}}
{% endif %}
</span>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
</span>
</div> <!-- .card -->
<!-- arrow -->
{% if sub_categories_size > 0 %}
<a
href="#{{ LIST_PREFIX }}{{ group_index }}"
data-toggle="collapse"
aria-expanded="true"
aria-label="{{ HEAD_PREFIX }}{{ group_index }}-trigger"
class="category-trigger hide-border-bottom"
>
<i class="fas fa-fw fa-angle-down"></i>
</a>
{% else %}
<span data-toggle="collapse" class="category-trigger hide-border-bottom disabled">
<i class="fas fa-fw fa-angle-right"></i>
</span>
{% endif %}
</div>
<!-- .card-header -->
<!-- Sub-categories -->
{% if sub_categories_size > 0 %}
<div id="{{ LIST_PREFIX }}{{ group_index }}" class="collapse show" aria-expanded="true">
<ul class="list-group">
{% for sub_category in sub_categories %}
<li class="list-group-item">
<i class="far fa-folder fa-fw"></i>
{% capture _sub_ctg_url %}/categories/{{ sub_category | slugify | url_encode }}/{% endcapture %}
<a href="{{ _sub_ctg_url | relative_url }}" class="ml-1 mr-2">{{ sub_category }}</a>
{% assign posts_size = site.categories[sub_category] | size %}
<span class="text-muted small font-weight-light">
{{ posts_size }}
{% if posts_size > 1 %}
{{
site.data.locales[lang].categories.post_measure.plural
| default: site.data.locales[lang].categories.post_measure
}}
{% else %}
{{
site.data.locales[lang].categories.post_measure.singular
| default: site.data.locales[lang].categories.post_measure
}}
{% endif %}
</span>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
</div>
<!-- .card -->
{% assign group_index = group_index | plus: 1 %}
{% endif %}
{% endfor %}

View File

@@ -3,6 +3,8 @@ layout: page
# The Category layout
---
{% include lang.html %}
<div id="page-category">
<h1 class="pl-lg-2">
<i class="far fa-folder-open fa-fw text-muted"></i>
@@ -12,11 +14,11 @@ layout: page
<ul class="post-content pl-0">
{% for post in page.posts %}
<li class="d-flex justify-content-between pl-md-3 pr-md-3">
<a href="{{ post.url | relative_url }}">{{ post.title }}</a>
<span class="dash flex-grow-1"></span>
{% include datetime.html date=post.date wrap='span' class='text-muted small' %}
</li>
<li class="d-flex justify-content-between pl-md-3 pr-md-3">
<a href="{{ post.url | relative_url }}">{{ post.title }}</a>
<span class="dash flex-grow-1"></span>
{% include datetime.html date=post.date wrap='span' class='text-muted small' lang=lang %}
</li>
{% endfor %}
</ul>
</div>

View File

@@ -3,10 +3,12 @@ layout: compress
# Default layout
---
<!DOCTYPE html>
<!doctype html>
{% include assets-origin.html %}
{% include lang.html %}
{% capture prefer_mode %}
{% if site.theme_mode %}
data-mode="{{ site.theme_mode }}"
@@ -14,26 +16,24 @@ layout: compress
{% endcapture %}
<!-- `site.alt_lang` can specify a language different from the UI -->
<html lang="{{ site.alt_lang | default: site.lang }}"{{ prefer_mode }}>
<html lang="{{ site.alt_lang | default: site.lang }}" {{ prefer_mode }}>
{% include head.html %}
<body data-topbar-visible="true">
{% include sidebar.html lang=lang %}
{% include sidebar.html %}
{% include topbar.html %}
{% include topbar.html lang=lang %}
<div id="main-wrapper" class="d-flex justify-content-center">
<div id="main" class="container pl-xl-4 pr-xl-4">
{{ content }}
</div>
{% include search-results.html %}
{% include search-results.html lang=lang %}
</div>
<!-- #main-wrapper -->
</div> <!-- #main-wrapper -->
{% include footer.html %}
{% include footer.html lang=lang %}
{% if page.mermaid %}
{% include mermaid.html %}
@@ -46,17 +46,24 @@ layout: compress
</a>
{% if site.pwa.enabled %}
<div id="notification" class="toast" role="alert" aria-live="assertive" aria-atomic="true"
data-animation="true" data-autohide="false">
<div
id="notification"
class="toast"
role="alert"
aria-live="assertive"
aria-atomic="true"
data-animation="true"
data-autohide="false"
>
<div class="toast-header">
<button type="button" class="ml-2 ml-auto close" data-dismiss="toast" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="toast-body text-center pt-0">
<p class="pl-2 pr-2 mb-3">{{ site.data.locales[site.lang].notification.update_found }}</p>
<p class="pl-2 pr-2 mb-3">{{ site.data.locales[lang].notification.update_found }}</p>
<button type="button" class="btn btn-primary" aria-label="Update">
{{ site.data.locales[site.lang].notification.update }}
{{ site.data.locales[lang].notification.update }}
</button>
</div>
</div>
@@ -65,7 +72,5 @@ layout: compress
{% include search-loader.html %}
{% include js-selector.html %}
</body>
</html>

View File

@@ -3,6 +3,8 @@ layout: page
# The Home page layout
---
{% include lang.html %}
{% assign pinned = site.posts | where: 'pin', 'true' %}
{% assign default = site.posts | where_exp: 'item', 'item.pin != true and item.hidden != true' %}
@@ -58,7 +60,7 @@ layout: page
<div class="mr-auto">
<!-- posted date -->
<i class="far fa-calendar fa-fw"></i>
{% include datetime.html date=post.date %}
{% include datetime.html date=post.date lang=lang %}
<!-- categories -->
{% if post.categories.size > 0 %}
@@ -75,7 +77,7 @@ layout: page
{% if post.pin %}
<div class="pin">
<i class="fas fa-thumbtack fa-fw"></i>
<span>{{ site.data.locales[site.lang].post.pin_prompt }}</span>
<span>{{ site.data.locales[lang].post.pin_prompt }}</span>
</div>
{% endif %}
</div>

View File

@@ -4,60 +4,58 @@ layout: default
{% include assets-origin.html %}
<div class="row">
{% include lang.html %}
<div class="row">
<!-- core -->
<div id="core-wrapper" class="col-12 col-lg-11 col-xl-9 pr-xl-4">
<div class="post pl-1 pr-1 pl-md-2 pr-md-2">
{% capture _content %}
{% capture _content %}
{% if layout.refactor or page.layout == 'page' %}
{% include refactor-content.html content=content %}
{% include refactor-content.html content=content lang=lang %}
{% else %}
{{ content }}
{% endif %}
{% endcapture %}
{% if page.layout == 'page' or page.collection == 'tabs' %}
{% assign tab_key = page.title | downcase %}
{% assign title = site.data.locales[site.lang].tabs[tab_key] | default: page.title %}
<h1 class="dynamic-title">
{{ title }}
</h1>
<div class="post-content">
{% if page.layout == 'page' or page.collection == 'tabs' %}
{% assign tab_key = page.title | downcase %}
{% assign title = site.data.locales[lang].tabs[tab_key] | default: page.title %}
<h1 class="dynamic-title">
{{ title }}
</h1>
<div class="post-content">
{{ _content }}
</div>
{% else %}
{{ _content }}
</div>
{% else %}
{{ _content }}
{% endif %}
{% endif %}
</div>
</div> <!-- #core-wrapper -->
</div>
<!-- #core-wrapper -->
<!-- panel -->
<div id="panel-wrapper" class="col-xl-3 pl-2 text-muted">
<div class="access">
{% include update-list.html %}
{% include trending-tags.html %}
{% include update-list.html lang=lang %}
{% include trending-tags.html lang=lang %}
</div>
{% for _include in layout.panel_includes %}
{% assign _include_path = _include | append: '.html' %}
{% include {{ _include_path }} %}
{% include {{ _include_path }} lang=lang %}
{% endfor %}
</div>
</div>
<!-- tail -->
{% if layout.tail_includes %}
<div class="row">
<div id="tail-wrapper" class="col-12 col-lg-11 col-xl-9 pl-3 pr-3 pr-xl-4 mt-5">
{% for _include in layout.tail_includes %}
{% assign _include_path = _include | append: '.html' %}
{% include {{ _include_path }} %}
{% endfor %}
<div class="row">
<div id="tail-wrapper" class="col-12 col-lg-11 col-xl-9 pl-3 pr-3 pr-xl-4 mt-5">
{% for _include in layout.tail_includes %}
{% assign _include_path = _include | append: '.html' %}
{% include {{ _include_path }} lang=lang %}
{% endfor %}
</div>
</div>
</div>
{% endif %}

View File

@@ -9,20 +9,22 @@ tail_includes:
- comments
---
{% include lang.html %}
<h1 data-toc-skip>{{ page.title }}</h1>
<div class="post-meta text-muted">
<!-- published date -->
<span>
{{ site.data.locales[site.lang].post.posted }}
{% include datetime.html date=page.date tooltip=true %}
{{ site.data.locales[lang].post.posted }}
{% include datetime.html date=page.date tooltip=true lang=lang %}
</span>
<!-- lastmod date -->
{% if page.last_modified_at %}
<span>
{{ site.data.locales[site.lang].post.updated }}
{% include datetime.html date=page.last_modified_at tooltip=true %}
{{ site.data.locales[lang].post.updated }}
{% include datetime.html date=page.last_modified_at tooltip=true lang=lang %}
</span>
{% endif %}
@@ -54,7 +56,7 @@ tail_includes:
{% assign authors = page.authors %}
{% endif %}
{{ site.data.locales[site.lang].post.written_by }}
{{ site.data.locales[lang].post.written_by }}
<em>
{% if authors %}
@@ -75,12 +77,12 @@ tail_includes:
<em id="pv" class="pageviews">
<i class="fas fa-spinner fa-spin fa-fw"></i>
</em>
{{ site.data.locales[site.lang].post.pageview_measure }}
{{ site.data.locales[lang].post.pageview_measure }}
</span>
{% endif %}
<!-- read time -->
{% include read-time.html content=content prompt=true %}
{% include read-time.html content=content prompt=true lang=lang %}
</div>
</div> <!-- .d-flex -->
@@ -121,20 +123,20 @@ tail_includes:
d-flex justify-content-between align-items-center mt-3 pt-5 pb-2">
<div class="license-wrapper">
{% if site.data.locales[site.lang].copyright.license.template %}
{% if site.data.locales[lang].copyright.license.template %}
{% capture _replacement %}
<a href="{{ site.data.locales[site.lang].copyright.license.link }}">
{{ site.data.locales[site.lang].copyright.license.name }}
<a href="{{ site.data.locales[lang].copyright.license.link }}">
{{ site.data.locales[lang].copyright.license.name }}
</a>
{% endcapture %}
{{ site.data.locales[site.lang].copyright.license.template | replace: ':LICENSE_NAME', _replacement }}
{{ site.data.locales[lang].copyright.license.template | replace: ':LICENSE_NAME', _replacement }}
{% endif %}
</div>
{% include post-sharing.html %}
{% include post-sharing.html lang=lang %}
</div><!-- .post-tail-bottom -->

View File

@@ -3,6 +3,8 @@ layout: page
# The layout for Tag page
---
{% include lang.html %}
<div id="page-tag">
<h1 class="pl-lg-2">
<i class="fa fa-tag fa-fw text-muted"></i>
@@ -11,11 +13,11 @@ layout: page
</h1>
<ul class="post-content pl-0">
{% for post in page.posts %}
<li class="d-flex justify-content-between pl-md-3 pr-md-3">
<a href="{{ post.url | relative_url }}">{{ post.title }}</a>
<span class="dash flex-grow-1"></span>
{% include datetime.html date=post.date wrap='span' class='text-muted small' %}
</li>
<li class="d-flex justify-content-between pl-md-3 pr-md-3">
<a href="{{ post.url | relative_url }}">{{ post.title }}</a>
<span class="dash flex-grow-1"></span>
{% include datetime.html date=post.date wrap='span' class='text-muted small' lang=lang %}
</li>
{% endfor %}
</ul>
</div>