From b1c537c19f1a8586a99ea2aacd8435f201c2f74a Mon Sep 17 00:00:00 2001 From: Eltrac Date: Fri, 19 Sep 2025 09:09:07 +0800 Subject: feat(i18n): add English translation to date component --- i18n/en.yml | 9 +++++++++ i18n/zh.yml | 9 +++++++++ layouts/_partials/components/date.html | 23 ++++++++++++++--------- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/i18n/en.yml b/i18n/en.yml index 0a96d993..9c210c0a 100644 --- a/i18n/en.yml +++ b/i18n/en.yml @@ -41,3 +41,12 @@ settings: loremIpsum: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. sampleText: Aa otherOptions: Other Options +fuzzyTimes: + afterMidnight: After Midnight + earlyMorning: Early Morning + morning: Morning + noon: Noon + afternoon: Afternoon + evening: Evening + night: Night + midnight: Midnight diff --git a/i18n/zh.yml b/i18n/zh.yml index 4120717e..f246a18a 100644 --- a/i18n/zh.yml +++ b/i18n/zh.yml @@ -41,3 +41,12 @@ settings: loremIpsum: 对我个人而言,科学和人文谁更有意义不仅仅是一个重大的事件,还可能会改变我的人生。 我们都知道,只要有意义,那么就必须慎重考虑。问题的关键究竟为何? 在这种不可避免的冲突下,我们必须解决这个问题。 这样看来,我们一般认为,抓住了问题的关键,其他一切则会迎刃而解。从这个角度来看,生活中,若科学和人文谁更有意义出现了,我们就不得不考虑它出现了的事实。 塞内加曾经提到过,勇气通往天堂,怯懦通往地狱。这句话看似简单,但其中的阴郁不禁让人深思。所谓科学和人文谁更有意义,关键是科学和人文谁更有意义需要如何写。 那么,我们一般认为,抓住了问题的关键,其他一切则会迎刃而解。 sampleText: "字。" otherOptions: 其他选项 +fuzzyTimes: + afterMidnight: '凌晨' + earlyMorning: '清晨' + morning: '早上' + noon: '中午' + afternoon: '下午' + evening: '傍晚' + night: '晚上' + midnight: '深夜' diff --git a/layouts/_partials/components/date.html b/layouts/_partials/components/date.html index 1998202f..5b8b8278 100644 --- a/layouts/_partials/components/date.html +++ b/layouts/_partials/components/date.html @@ -1,15 +1,15 @@ {{ if .Date }} {{ $hour := .Date.Hour }} {{ $fuzzyTimes := slice - (dict "limit" 5 "label" "凌晨") - (dict "limit" 7 "label" "清晨") - (dict "limit" 11 "label" "早上") - (dict "limit" 13 "label" "中午") - (dict "limit" 17 "label" "下午") - (dict "limit" 19 "label" "傍晚") - (dict "limit" 22 "label" "晚上") + (dict "limit" 5 "label" (T "fuzzyTimes.afterMidnight")) + (dict "limit" 7 "label" (T "fuzzyTimes.earlyMorning")) + (dict "limit" 11 "label" (T "fuzzyTimes.morning")) + (dict "limit" 13 "label" (T "fuzzyTimes.noon")) + (dict "limit" 17 "label" (T "fuzzyTimes.afternoon")) + (dict "limit" 19 "label" (T "fuzzyTimes.evening")) + (dict "limit" 22 "label" (T "fuzzyTimes.night")) }} - {{ $fuzzyTime := "深夜" }} {{/* default */}} + {{ $fuzzyTime := (T "fuzzyTimes.midnight") }} {{/* default */}} {{ range $fuzzyTimes }} {{ if lt $hour .limit }} {{ $fuzzyTime = .label }} @@ -21,6 +21,11 @@ datetime="{{ .Date.Format "2006-01-02 15:04:05 MST" }}" data-pagefind-sort="date[datetime], weight[data-weight]" data-weight="{{ if .Params.featured }}30{{ else }}20{{ end }}"> - {{ .Date.Format "2006年1月2日" }} {{ $fuzzyTime }} + {{ if eq .Site.Language.Lang "zh" }} + {{ .Date.Format "2006年1月2日" }} + {{ else }} + {{ .Date.Format "January 2, 2006" }}, + {{ end }} + {{ $fuzzyTime }} {{ end }} -- cgit v1.2.3 From d007885a3e3f6feabefbfcf28d210cc43edc3650 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Fri, 19 Sep 2025 17:01:29 +0800 Subject: feat(i18n): add i18n support for action menu --- i18n/en.yml | 6 ++++++ i18n/zh.yml | 6 ++++++ layouts/_partials/posts/action-menu.html | 30 +++++++++++++++++++++--------- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/i18n/en.yml b/i18n/en.yml index 9c210c0a..a303a633 100644 --- a/i18n/en.yml +++ b/i18n/en.yml @@ -50,3 +50,9 @@ fuzzyTimes: evening: Evening night: Night midnight: Midnight +actionMenu: + telegramChannel: Telegram Channel + sponsor: Buy me a coffee + comment: Comment + like: Sacrifice your heart + liked: You've already made your sacrifice diff --git a/i18n/zh.yml b/i18n/zh.yml index f246a18a..37b2511d 100644 --- a/i18n/zh.yml +++ b/i18n/zh.yml @@ -50,3 +50,9 @@ fuzzyTimes: evening: '傍晚' night: '晚上' midnight: '深夜' +actionMenu: + telegramChannel: 'Telegram 频道' + sponsor: 赞助作者 + comment: 评论 + like: 为这篇文章献上心脏 + liked: 你已经献上心脏了 diff --git a/layouts/_partials/posts/action-menu.html b/layouts/_partials/posts/action-menu.html index 63c7ba5c..d05a61d1 100644 --- a/layouts/_partials/posts/action-menu.html +++ b/layouts/_partials/posts/action-menu.html @@ -3,8 +3,10 @@
@@ -15,25 +17,35 @@ hover:bg-black/5 hover:rounded-lg group animate-count-infinite" onclick="sendLike('{{ .File.UniqueID | urlize }}')" id="like-btn-{{ .File.UniqueID | urlize }}" - title="为这篇文章献上心脏" - data-liked-title="你已经献上心脏了" + title="{{ T "actionMenu.like" }}" + data-liked-title="{{ T "actionMenu.liked" }}" data-tooltip> - 点赞 + {{ T ...
+ {{ if eq .Site.Language.Lang "zh" }} + {{ end }} -- cgit v1.2.3