refactor: i18n

This commit is contained in:
olOwOlo 2018-01-31 22:07:50 +08:00
parent be7b6c63a4
commit 259d3dec1a
No known key found for this signature in database
GPG key ID: 456394B6E7A15EA6
16 changed files with 227 additions and 237 deletions

View file

@ -1,47 +0,0 @@
archive = "归档"
tags = "标签"
categories = "分类"
[footer]
powered = "由 %s 强力驱动"
theme = "主题"
[posts]
prev = "上一页"
next = "下一页"
prev_post = "上一篇"
next_post = "下一篇"
toc = "文章目录"
readmore = "阅读更多"
reward = "赞赏支持"
rewardAlipay = "支付宝打赏"
rewardWechat = "微信打赏"
seeMarkDown = "查看本文 Markdown 版本 »"
[posts.header]
wordCount = "约 %d 字"
readingTime = "预计阅读 %d 分钟"
[copyright]
author = "文章作者"
lastMod = "上次更新"
markdown = "原始文档"
license = "许可协议"
[counter]
[counter.archives]
zero = "暂无文章"
other = "共计 %d 篇文章"
[counter.tagcloud]
zero = "暂无标签"
other = "共计 %d 个标签"
[counter.categories]
zero = "暂无分类"
other = "共计 %d 个分类"
[traffic]
siteUV = "本站总访客数 %s 人"
sitePV = "本站总访问量 %s 次"
pagePV = "%s 次阅读"

View file

@ -1,47 +0,0 @@
archive = "Archive"
tags = "Tags"
categories = "Categories"
[footer]
powered = "Powered by %s"
theme = "Theme"
[posts]
prev = "Prev"
next = "Next"
prev_post = "Prev"
next_post = "Next"
toc = "Contents"
readmore = "Read more.."
reward = "Reward"
rewardAlipay = "alipay"
rewardWechat = "wechat"
seeMarkDown = "The Markdown version »"
[posts.header]
wordCount = "%d word"
readingTime = "%d min read"
[copyright]
author = "Author"
lastMod = "LastMod"
markdown = "Markdown"
license = "License"
[counter]
[counter.archives]
zero = "No Posts"
other = "%d Posts In Total"
[counter.tagcloud]
zero = "No tags"
other = "%d Tags In Total"
[counter.categories]
zero = "No Categories"
other = "%d Categories In Total"
[traffic]
siteUV = "site uv: %s"
sitePV = "site pv: %s"
pagePV = "%s times read"

View file

@ -1,47 +0,0 @@
archive = "归档"
tags = "标签"
categories = "分类"
[footer]
powered = "由 %s 强力驱动"
theme = "主题"
[posts]
prev = "上一页"
next = "下一页"
prev_post = "上一篇"
next_post = "下一篇"
toc = "文章目录"
readmore = "阅读更多"
reward = "赞赏支持"
rewardAlipay = "支付宝打赏"
rewardWechat = "微信打赏"
seeMarkDown = "查看本文 Markdown 版本 »"
[posts.header]
wordCount = "约 %d 字"
readingTime = "预计阅读 %d 分钟"
[copyright]
author = "文章作者"
lastMod = "上次更新"
markdown = "原始文档"
license = "许可协议"
[counter]
[counter.archives]
zero = "暂无文章"
other = "共计 %d 篇文章"
[counter.tagcloud]
zero = "暂无标签"
other = "共计 %d 个标签"
[counter.categories]
zero = "暂无分类"
other = "共计 %d 个分类"
[traffic]
siteUV = "本站总访客数 %s 人"
sitePV = "本站总访问量 %s 次"
pagePV = "%s 次阅读"

View file

@ -1,47 +0,0 @@
archive = "Archive"
tags = "Tags"
categories = "Categories"
[footer]
powered = "Powered by %s"
theme = "Theme"
[posts]
prev = "Prev"
next = "Next"
prev_post = "Prev"
next_post = "Next"
toc = "Contents"
readmore = "Read more.."
reward = "Reward"
rewardAlipay = "alipay"
rewardWechat = "wechat"
seeMarkDown = "The Markdown version »"
[posts.header]
wordCount = "%d word"
readingTime = "%d min read"
[copyright]
author = "Author"
lastMod = "LastMod"
markdown = "Markdown"
license = "License"
[counter]
[counter.archives]
zero = "No Posts"
other = "%d Posts In Total"
[counter.tagcloud]
zero = "No tags"
other = "%d Tags In Total"
[counter.categories]
zero = "No Categories"
other = "%d Categories In Total"
[traffic]
siteUV = "site uv: %s"
sitePV = "site pv: %s"
pagePV = "%s times read"

96
i18n/en.yaml Normal file
View file

@ -0,0 +1,96 @@
# ===== title =====
archive:
other: "Archive"
tags:
other: "Tags"
categories:
other: "Categories"
# ===== footer =====
powered:
other: "Powered by %s"
theme:
other: "Theme"
siteUV:
other: "site uv: %s"
sitePV:
other: "site pv: %s"
pagePV:
other: "%s times read"
# ===== post =====
prevPage:
other: "Prev"
nextPage:
other: "Next"
prevPost:
other: "Prev"
nextPost:
other: "Next"
toc:
other: "Contents"
readMore:
other: "Read more.."
reward:
other: "Reward"
rewardAlipay:
other: "alipay"
rewardWechat:
other: "wechat"
wordCount:
one: "{{ .Count }} word"
other: "{{ .Count }} words"
readingTime:
one: "{{ .Count }} min read"
other: "{{ .Count }} mins read"
# ===== content license =====
author:
other: "Author"
lastMod:
other: "LastMod"
markdown:
other: "Markdown"
seeMarkDown:
other: "The Markdown version »"
license:
other: "License"
# ===== counter =====
archiveCounter:
one: "{{ .Count }} Post In Total"
other: "{{ .Count }} Posts In Total"
tagCounter:
one: "{{ .Count }} Tag In Total"
other: "{{ .Count }} Tags In Total"
zeroTagCounter:
other: "No tags"
categoryCounter:
one: "{{ .Count }} Category In Total"
other: "{{ .Count }} Categories In Total"
zeroCategoryCounter:
other: "No categories"

96
i18n/zh-CN.yaml Normal file
View file

@ -0,0 +1,96 @@
# ===== title =====
archive:
other: "归档"
tags:
other: "标签"
categories:
other: "分类"
# ===== footer =====
powered:
other: "由 %s 强力驱动"
theme:
other: "主题"
siteUV:
other: "本站总访客数 %s 人"
sitePV:
other: "本站总访问量 %s 次"
pagePV:
other: "%s 次阅读"
# ===== post =====
prevPage:
other: "上一页"
nextPage:
other: "下一页"
prevPost:
other: "上一篇"
nextPost:
other: "下一篇"
toc:
other: "文章目录"
readMore:
other: "阅读更多"
reward:
other: "赞赏支持"
rewardAlipay:
other: "支付宝打赏"
rewardWechat:
other: "微信打赏"
wordCount:
one: "约 {{ .Count }} 字"
other: "约 {{ .Count }} 字"
readingTime:
one: "预计阅读 {{ .Count }} 分钟"
other: "预计阅读 {{ .Count }} 分钟"
# ===== content license =====
author:
other: "文章作者"
lastMod:
other: "上次更新"
markdown:
other: "原始文档"
seeMarkDown:
other: "查看本文 Markdown 版本 »"
license:
other: "许可协议"
# ===== counter =====
archiveCounter:
one: "共计 {{ .Count }} 篇文章"
other: "共计 {{ .Count }} 篇文章"
tagCounter:
one: "共计 {{ .Count }} 个标签"
other: "共计 {{ .Count }} 个标签"
zeroTagCounter:
other: "暂无标签"
categoryCounter:
one: "共计 {{ .Count }} 个分类"
other: "共计 {{ .Count }} 个分类"
zeroCategoryCounter:
other: "暂无分类"

View file

@ -1,18 +1,12 @@
{{ define "title" }}{{ .Site.Data.even.default.archive }} - {{ .Site.Title }}{{ end }}
{{ define "title" }}{{ T "archive" }} - {{ .Site.Title }}{{ end }}
{{ define "content"}}
{{- $lang := .Site.Data.even.default }}
{{- $paginator := .Paginate (where .Data.Pages.ByDate.Reverse "Type" "post") (index .Site.Params "archive-paginate") }}
<section id="archive" class="archive">
{{- if not $paginator.HasPrev }}
<div class="archive-title">
<span class="archive-post-counter">
{{- $length := len .Data.Pages }}
{{- if eq $length 0 }}
{{ $lang.counter.archives.zero }}
{{ else }}
{{ printf $lang.counter.archives.other $length }}
{{ end -}}
{{ T "archiveCounter" (len .Data.Pages) }}
</span>
</div>
{{- end -}}
@ -43,12 +37,12 @@
{{ with $paginator.Prev -}}
<a class="prev" href="{{ .URL }}">
<i class="iconfont icon-left"></i>
<span class="prev-text">{{ $lang.posts.prev }}</span>
<span class="prev-text">{{ T "prevPage" }}</span>
</a>
{{- end }}
{{ with $paginator.Next -}}
<a class="next" href="{{ .URL }}">
<span class="next-text">{{ $lang.posts.next }}</span>
<span class="next-text">{{ T "nextPage" }}</span>
<i class="iconfont icon-right"></i>
</a>
{{- end }}

View file

@ -30,16 +30,15 @@
</section>
<!-- pagination -->
<nav class="pagination">
{{- $lang := .Site.Data.even.default -}}
{{ with $paginator.Prev }}
<a class="prev" href="{{ .URL }}">
<i class="iconfont icon-left"></i>
<span class="prev-text">{{ $lang.posts.prev }}</span>
<span class="prev-text">{{ T "prevPage" }}</span>
</a>
{{- end }}
{{ with $paginator.Next }}
<a class="next" href="{{ .URL }}">
<span class="next-text">{{ $lang.posts.next }}</span>
<span class="next-text">{{ T "nextPage" }}</span>
<i class="iconfont icon-right"></i>
</a>
{{- end }}

View file

@ -1,7 +1,6 @@
{{ define "title" }}{{ index .Site.Data.even.default .Data.Plural }} - {{ .Site.Title }}{{ end }}
{{ define "title" }}{{ T .Data.Plural }} - {{ .Site.Title }}{{ end }}
{{ define "content" }}
{{ $lang := .Site.Data.even.default -}}
{{ $name := .Data.Plural -}}
{{ $terms := .Data.Terms.ByCount -}}
{{ $length := len $terms -}}
@ -9,9 +8,9 @@
<div class="categories">
<div class="categories-title">
{{ if eq $length 0 }}
{{ $lang.counter.categories.zero }}
{{ T "zeroCategoryCounter" }}
{{ else }}
{{ printf $lang.counter.categories.other $length }}
{{ T "categoryCounter" $length }}
{{ end }}
</div>
<div class="categories-tags">
@ -26,10 +25,10 @@
{{ else if eq $name "tags" }}
<div class="tag-cloud">
<div class="tag-cloud-title">
{{ if eq $length 0 }}
{{ $lang.counter.tagcloud.zero }}
{{ if eq $length 0 }}
{{ T "zeroTagCounter" }}
{{ else }}
{{ printf $lang.counter.tagcloud.other $length}}
{{ T "tagCounter" $length }}
{{ end }}
</div>
<div class="tag-cloud-tags">

View file

@ -8,16 +8,15 @@
</section>
<!-- pagination -->
<nav class="pagination">
{{- $lang := .Site.Data.even.default -}}
{{ with $paginator.Prev }}
<a class="prev" href="{{ .URL }}">
<i class="iconfont icon-left"></i>
<span class="prev-text">{{ $lang.posts.prev }}</span>
<span class="prev-text">{{ T "prevPage" }}</span>
</a>
{{- end }}
{{ with $paginator.Next }}
<a class="next" href="{{ .URL }}">
<span class="next-text">{{ $lang.posts.next }}</span>
<span class="next-text">{{ T "nextPage" }}</span>
<i class="iconfont icon-right"></i>
</a>
{{- end }}

View file

@ -1,4 +1,3 @@
{{ $lang := .Site.Data.even.default -}}
<div class="social-links">
{{- range $name, $path := .Site.Params.social }}
{{- if $path }}
@ -15,11 +14,11 @@
<div class="copyright">
<span class="power-by">
{{ (printf $lang.footer.powered `<a class="hexo-link" href="https://gohugo.io">Hugo</a>`) | safeHTML }}
{{ (printf (T "powered") `<a class="hexo-link" href="https://gohugo.io">Hugo</a>`) | safeHTML }}
</span>
<span class="division">|</span>
<span class="theme-info">
{{ $lang.footer.theme }} -
{{ T "theme" }} -
<a class="theme-link" href="https://github.com/olOwOlo/hugo-theme-even">Even</a>
</span>
@ -28,12 +27,12 @@
{{ $spinner := "img/spinner.svg" | relURL -}}
{{ if and .Site.Params.busuanzi.enable .Site.Params.busuanzi.sitePV -}}
{{ $valueSpan := printf `<span id="busuanzi_value_site_pv"><img src="%s" alt="spinner.svg"/></span>` $spinner -}}
<span id="busuanzi_container_site_pv"> {{ printf $lang.traffic.sitePV $valueSpan | safeHTML }} </span>
<span id="busuanzi_container_site_pv"> {{ printf (T "sitePV") $valueSpan | safeHTML }} </span>
{{ if .Site.Params.busuanzi.siteUV }}<span class="division">|</span>{{ end }}
{{- end }}
{{ if and .Site.Params.busuanzi.enable .Site.Params.busuanzi.siteUV -}}
{{ $valueSpan := printf `<span id="busuanzi_value_site_uv"><img src="%s" alt="spinner.svg"/></span>` $spinner -}}
<span id="busuanzi_container_site_uv"> {{ printf $lang.traffic.siteUV $valueSpan | safeHTML }} </span>
<span id="busuanzi_container_site_uv"> {{ printf (T "siteUV") $valueSpan | safeHTML }} </span>
{{- end }}
</div>
{{- end }}

View file

@ -1,24 +1,23 @@
{{ if or .Params.contentCopyright (and .Site.Params.contentCopyright (ne .Params.contentCopyright false)) }}
{{ $lang := .Site.Data.even.default -}}
<div class="post-copyright">
<p class="copyright-item">
<span class="item-title">{{ $lang.copyright.author }}</span>
<span class="item-title">{{ T "author" }}</span>
<span class="item-content">{{ if .Params.author }}{{ .Params.author | safeHTML }}{{ else }}{{ .Site.Author.name | safeHTML }}{{ end }}</span>
</p>
<p class="copyright-item">
<span class="item-title">{{ $lang.copyright.lastMod }}</span>
<span class="item-title">{{ T "lastMod" }}</span>
<span class="item-content">{{ .Lastmod.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }}</span>
</p>
{{ if $.Site.Params.linkToMarkDown -}}
{{ with $.OutputFormats.Get "markdown" -}}
<p class="copyright-item">
<span class="item-title">{{ $lang.copyright.markdown }}</span>
<span class="item-content"><a class="link-to-markdown" href="{{ .Permalink }}" target="_blank">{{ $lang.posts.seeMarkDown }}</a></span>
<span class="item-title">{{ T "markdown" }}</span>
<span class="item-content"><a class="link-to-markdown" href="{{ .Permalink }}" target="_blank">{{ T "seeMarkDown" }}</a></span>
</p>
{{- end }}
{{- end }}
<p class="copyright-item">
<span class="item-title">{{ $lang.copyright.license }}</span>
<span class="item-title">{{ T "license" }}</span>
<span class="item-content">
{{- if .Params.contentCopyright -}}
{{ .Params.contentCopyright | safeHTML }}

View file

@ -1,20 +1,19 @@
{{ if or .Params.reward (and .Site.Params.reward.enable (ne .Params.reward false)) }}
<div class="post-reward">
{{- $lang := .Site.Data.even.default }}
<input type="checkbox" name="reward" id="reward" hidden />
<label class="reward-button" for="reward">{{ $lang.posts.reward }}</label>
<label class="reward-button" for="reward">{{ T "reward" }}</label>
<div class="qr-code">
{{ $qrCode := .Site.Params.reward }}
{{ with $qrCode.wechat }}
<label class="qr-code-image" for="reward">
<img class="image" src="{{ . }}">
<span>{{ $lang.posts.rewardWechat }}</span>
<span>{{ T "rewardWechat" }}</span>
</label>
{{- end }}
{{ with $qrCode.alipay }}
<label class="qr-code-image" for="reward">
<img class="image" src="{{ . }}">
<span>{{ $lang.posts.rewardAlipay }}</span>
<span>{{ T "rewardAlipay" }}</span>
</label>
{{- end }}
</div>

View file

@ -1,6 +1,6 @@
{{ if or .Params.toc (and .Site.Params.toc (ne .Params.toc false)) }}
<div class="post-toc" id="post-toc">
<h2 class="post-toc-title">{{ .Site.Data.even.default.posts.toc }}</h2>
<h2 class="post-toc-title">{{ T "toc" }}</h2>
{{ $globalAutoCollapseToc := .Site.Params.autoCollapseToc | default false }}
<div class="post-toc-content{{ if not (or .Params.autoCollapseToc (and $globalAutoCollapseToc (ne .Params.autoCollapseToc false))) }} always-active{{ end }}">
{{.TableOfContents}}

View file

@ -1,5 +1,4 @@
{{ define "content" -}}
{{ $lang := .Site.Data.even.default -}}
<article class="post">
<!-- post-header -->
<header class="post-header">
@ -15,12 +14,12 @@
</div>
{{- end }}
{{ if .Site.Params.moreMeta -}}
<span class="more-meta"> {{ printf $lang.posts.header.wordCount .WordCount }} </span>
<span class="more-meta"> {{ printf $lang.posts.header.readingTime .ReadingTime }} </span>
<span class="more-meta"> {{ T "wordCount" .WordCount }} </span>
<span class="more-meta"> {{ T "readingTime" .ReadingTime }} </span>
{{- end }}
{{ if and .Site.Params.busuanzi.enable .Site.Params.busuanzi.pagePV -}}
{{ $valueSpan := printf `<span id="busuanzi_value_page_pv"><img src="%s" alt="spinner.svg"/></span>` ("img/spinner.svg" | relURL) -}}
<span id="busuanzi_container_page_pv" class="more-meta"> {{ printf $lang.traffic.pagePV $valueSpan | safeHTML }} </span>
<span id="busuanzi_container_page_pv" class="more-meta"> {{ printf (T "pagePV") $valueSpan | safeHTML }} </span>
{{- end }}
</div>
</header>
@ -54,13 +53,13 @@
<a class="prev" href="{{ .URL }}">
<i class="iconfont icon-left"></i>
<span class="prev-text nav-default">{{ .Title }}</span>
<span class="prev-text nav-mobile">{{ $lang.posts.prev_post }}</span>
<span class="prev-text nav-mobile">{{ T "prevPost" }}</span>
</a>
{{- end }}
{{ with .PrevInSection }}
<a class="next" href="{{ .URL }}">
<span class="next-text nav-default">{{ .Title }}</span>
<span class="prev-text nav-mobile">{{ $lang.posts.next_post }}</span>
<span class="prev-text nav-mobile">{{ T "nextPost" }}</span>
<i class="iconfont icon-right"></i>
</a>
{{- end }}

View file

@ -1,4 +1,3 @@
{{ $lang := .Site.Data.even.default -}}
<article class="post">
<header class="post-header">
<h1 class="post-title"><a class="post-link" href="{{ .URL }}">{{ .Title }}</a></h1>
@ -12,8 +11,8 @@
</div>
{{- end }}
{{ if .Site.Params.moreMeta -}}
<span class="more-meta"> {{ printf $lang.posts.header.wordCount .WordCount }} </span>
<span class="more-meta"> {{ printf $lang.posts.header.readingTime .ReadingTime }} </span>
<span class="more-meta"> {{ T "wordCount" .WordCount }} </span>
<span class="more-meta"> {{ T "readingTime" .ReadingTime }} </span>
{{- end }}
</div>
</header>
@ -23,7 +22,7 @@
{{ .Summary }}
</div>
<div class="read-more">
<a href="{{ .URL }}" class="read-more-link">{{ $lang.posts.readmore }}</a>
<a href="{{ .URL }}" class="read-more-link">{{ T "readMore" }}</a>
</div>
</div>
</article>