From 0213331a1645969c72e488b6067f9340394b5872 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sun, 1 Aug 2021 21:54:27 +0800 Subject: [PATCH] Improve the way to set the default value of locales --- _config.yml | 5 +++-- _includes/footer.html | 6 +++--- _includes/head.html | 10 +++++----- _includes/lang.html | 8 ++++++++ _includes/panel.html | 8 +++++--- _includes/post-nav.html | 8 ++++---- _includes/post-sharing.html | 6 +++--- _includes/read-time.html | 6 +++--- _includes/related-posts.html | 2 +- _includes/search-results.html | 2 +- _includes/sidebar.html | 4 ++-- _includes/timeago.html | 6 +++--- _includes/topbar.html | 18 +++++++++--------- _layouts/archives.html | 4 +++- _layouts/categories.html | 8 +++++--- _layouts/category.html | 4 +++- _layouts/default.html | 4 +++- _layouts/home.html | 4 +++- _layouts/page.html | 2 +- _layouts/post.html | 16 +++++++++------- _layouts/tag.html | 4 +++- assets/404.html | 10 ++++++---- assets/feed.xml | 2 +- 23 files changed, 87 insertions(+), 60 deletions(-) create mode 100644 _includes/lang.html diff --git a/_config.yml b/_config.yml index 10c213f..734598f 100644 --- a/_config.yml +++ b/_config.yml @@ -7,8 +7,9 @@ theme: jekyll-theme-chirpy # change below value to '/projectname'. baseurl: '' -# The language of the site layout › http://www.lingoes.net/en/translator/langcode.htm -# Go to folder '_data/locales' to check the available language options +# The language of the webpage › http://www.lingoes.net/en/translator/langcode.htm +# If it has the same name as one of the files in folder `_data/locales`, the layout language will also be changed, +# otherwise, the layout language will use the default value of 'en'. lang: en # Change to your timezone › http://www.timezoneconverter.com/cgi-bin/findzone/findzone diff --git a/_includes/footer.html b/_includes/footer.html index d84c8bb..582cb4c 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -8,9 +8,9 @@

© {{ 'now' | date: "%Y" }} {{ site.social.name }}. - {% if site.data.locales[site.lang].copyright.brief %} + {% if site.data.locales[lang].copyright.brief %} {{ site.data.locales[site.lang].copyright.brief }} + title="{{ site.data.locales[lang].copyright.verbose }}">{{ site.data.locales[lang].copyright.brief }} {% endif %}

@@ -25,7 +25,7 @@ Chirpy {% endcapture %} - {{ site.data.locales[site.lang].meta + {{ site.data.locales[lang].meta | default: 'Powered by :PLATFORM with :THEME theme.' | replace: ':PLATFORM', _platform | replace: ':THEME', _theme }} diff --git a/_includes/head.html b/_includes/head.html index 47e616d..710d47d 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -8,11 +8,11 @@ {% if page.layout == 'home' or page.layout == 'post' %} - - - - - + + + + + {% if site.google_analytics.pv.proxy_endpoint %} diff --git a/_includes/lang.html b/_includes/lang.html new file mode 100644 index 0000000..656f200 --- /dev/null +++ b/_includes/lang.html @@ -0,0 +1,8 @@ +{% comment %} +Detect appearance language and return it through variable "lang" +{% endcomment %} +{% if site.data.locales[site.lang] %} + {% assign lang = site.lang %} +{% else %} + {% assign lang = 'en' %} +{% endif %} diff --git a/_includes/panel.html b/_includes/panel.html index bfa881b..98b859c 100644 --- a/_includes/panel.html +++ b/_includes/panel.html @@ -2,6 +2,8 @@ The Pannel on right side (Desktop views) --> +{% include lang.html %} +
@@ -11,7 +13,7 @@ {% if update_list.size > 0 %}
- {{- site.data.locales[site.lang].panel.lastmod | default: 'Recent Update' -}} + {{- site.data.locales[lang].panel.lastmod -}}
    {% for item in update_list %} @@ -30,7 +32,7 @@ {% if trending_tags.size > 0 %}
    - {{- site.data.locales[site.lang].panel.trending_tags | default: 'Trending Tags' -}} + {{- site.data.locales[lang].panel.trending_tags -}}
    {% for tag_name in trending_tags %} @@ -48,7 +50,7 @@
    - {{- site.data.locales[site.lang].panel.toc | default: 'Contents' -}} + {{- site.data.locales[lang].panel.toc -}}
    diff --git a/_includes/post-nav.html b/_includes/post-nav.html index c9c258c..bb3b52d 100644 --- a/_includes/post-nav.html +++ b/_includes/post-nav.html @@ -5,24 +5,24 @@
    {% if page.previous.url %} + prompt="{{ site.data.locales[lang].post.button.previous }}">

    {{ page.previous.title }}

    {% else %} + prompt="{{ site.data.locales[lang].post.button.previous }}">

    -

    {% endif %} {% if page.next.url %} + prompt="{{ site.data.locales[lang].post.button.next }}">

    {{ page.next.title }}

    {% else %} + prompt="{{ site.data.locales[lang].post.button.next }}">

    -

    {% endif %} diff --git a/_includes/post-sharing.html b/_includes/post-sharing.html index 252370f..4bf7d8d 100644 --- a/_includes/post-sharing.html +++ b/_includes/post-sharing.html @@ -3,7 +3,7 @@ -->