From f904e8cd48c343cc31e25859d9d50bfe2c056f41 Mon Sep 17 00:00:00 2001
From: Cotes Chung <11371340+cotes2020@users.noreply.github.com>
Date: Wed, 19 Oct 2022 02:49:31 +0800
Subject: [PATCH] refactor(locale): restore options for changing date format
(#716)
---
_data/locales/en.yml | 10 ++++++++++
_data/locales/ko-KR.yml | 7 +++++++
_data/locales/zh-CN.yml | 7 +++++++
_includes/datetime.html | 10 ++--------
_layouts/archives.html | 9 ++-------
5 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/_data/locales/en.yml b/_data/locales/en.yml
index 14394a6..79b42e1 100644
--- a/_data/locales/en.yml
+++ b/_data/locales/en.yml
@@ -73,6 +73,16 @@ post:
# pinned prompt of posts list on homepage
pin_prompt: Pinned
+# Date time format.
+# See: ,
+df:
+ post:
+ strftime: '%b %e, %Y'
+ dayjs: 'll'
+ archives:
+ strftime: '%b'
+ dayjs: 'MMM'
+
# categories page
categories:
category_measure:
diff --git a/_data/locales/ko-KR.yml b/_data/locales/ko-KR.yml
index 2fb9391..73e1ded 100644
--- a/_data/locales/ko-KR.yml
+++ b/_data/locales/ko-KR.yml
@@ -73,6 +73,13 @@ post:
# pinned prompt of posts list on homepage
pin_prompt: 핀
+# Date time format.
+# See: ,
+df:
+ post:
+ strftime: '%Y/%m/%d'
+ dayjs: 'YYYY/MM/DD'
+
# categories page
categories:
category_measure: 카테고리
diff --git a/_data/locales/zh-CN.yml b/_data/locales/zh-CN.yml
index 87fa2dc..1463e95 100644
--- a/_data/locales/zh-CN.yml
+++ b/_data/locales/zh-CN.yml
@@ -72,6 +72,13 @@ post:
# pinned prompt of posts list on homepage
pin_prompt: 顶置
+# Date time format.
+# See: ,
+df:
+ post:
+ strftime: '%Y/%m/%d'
+ dayjs: 'YYYY/MM/DD'
+
# categories page
categories:
category_measure: 个分类
diff --git a/_includes/datetime.html b/_includes/datetime.html
index 47e38bd..d6e9d5e 100644
--- a/_includes/datetime.html
+++ b/_includes/datetime.html
@@ -4,14 +4,8 @@
-->
{% assign wrap_elem = include.wrap | default: 'em' %}
-
-{% if site.prefer_datetime_locale == 'en' or lang == 'en' %}
- {% assign df_strftime = '%b %e, %Y' %}
- {% assign df_dayjs = 'll' %}
-{% else %}
- {% assign df_strftime = '%F' %}
- {% assign df_dayjs = 'YYYY-MM-DD' %}
-{% endif %}
+{% assign df_strftime = site.data.locales[lang].df.post.strftime | default: '%d/%m/%Y' %}
+{% assign df_dayjs = site.data.locales[lang].df.post.dayjs | default: 'DD/MM/YYYY' %}
<{{ wrap_elem }} class="{% if include.class %}{{ include.class }}{% endif %}"
data-ts="{{ include.date | date: '%s' }}"
diff --git a/_layouts/archives.html b/_layouts/archives.html
index 61ad91d..fd482e5 100644
--- a/_layouts/archives.html
+++ b/_layouts/archives.html
@@ -5,13 +5,8 @@ layout: page
{% include lang.html %}
-{% if site.prefer_datetime_locale == 'en' or lang == 'en' %}
- {% assign df_strftime_m = '%b' %}
- {% assign df_dayjs_m = 'MMM' %}
-{% else %}
- {% assign df_strftime_m = '/ %m' %}
- {% assign df_dayjs_m = '/ MM' %}
-{% endif %}
+{% 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' %}