fix(i18n): fix Valine Comment System i18n bug

This commit is contained in:
Dillon ZENG 2019-11-23 13:42:26 +08:00
parent 473900da79
commit 69aa0cd779
5 changed files with 31 additions and 27 deletions

View file

@ -28,6 +28,11 @@ other = "Categories"
other = "More" other = "More"
# === Pagination === # === Pagination ===
# === partials/comments.html ===
[valineLang]
other = "en"
# === partials/comments.html ===
# === partials/footer.html === # === partials/footer.html ===
[powered] [powered]
other = "Powered by %s" other = "Powered by %s"

View file

@ -28,6 +28,11 @@ other = "分类"
other = "更多" other = "更多"
# === Pagination === # === Pagination ===
# === partials/comments.html ===
[valineLang]
other = "zh-cn"
# === partials/comments.html ===
# === partials/footer.html === # === partials/footer.html ===
[powered] [powered]
other = "由 %s 强力驱动" other = "由 %s 强力驱动"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 KiB

After

Width:  |  Height:  |  Size: 225 KiB

View file

@ -57,9 +57,7 @@
{{ .Site.Params.cdn.valine_js | safeHTML }} {{ .Site.Params.cdn.valine_js | safeHTML }}
{{ else }} {{ else }}
{{- $res := resources.Get "js/lib/valine/Valine.min.js" | resources.Minify -}} {{- $res := resources.Get "js/lib/valine/Valine.min.js" | resources.Minify -}}
{{ .Site.Params.cdn.fontawesome_free_css | safeHTML }} <script src="{{ $res.RelPermalink }}"></script>
{{ .Site.Params.cdn.fontawesome_free_css | safeHTML }}
<script src="{{ $res.RelPermalink }}"></script>
{{ end }} {{ end }}
<script type="text/javascript"> <script type="text/javascript">
new Valine({ new Valine({
@ -73,6 +71,7 @@
placeholder: "{{ .Site.Params.valine.placeholder }}", placeholder: "{{ .Site.Params.valine.placeholder }}",
visitor: "{{ .Site.Params.valine.visitor }}", visitor: "{{ .Site.Params.valine.visitor }}",
recordIP: "{{ .Site.Params.valine.recordIP }}", recordIP: "{{ .Site.Params.valine.recordIP }}",
lang: "{{ T `valineLang` }}",
}); });
</script> </script>
{{- end -}} {{- end -}}

View file

@ -1,31 +1,26 @@
{{ $pag := $.Paginator }} {{ if gt $.paginator.TotalPages 1 -}}
{{ if gt $pag.TotalPages 1 }}
<ul class="pagination"> <ul class="pagination">
{{ with $pag.First }} {{- $.Scratch.Set "paginator.ellipsed" false -}}
{{ end }} {{ range $.paginator.Pagers -}}
{{ $right := sub .TotalPages .PageNumber -}}
{{ $.Scratch.Set "__paginator.ellipsed" false }} {{ $showNumber := or (le .PageNumber 1) (eq $right 0) -}}
{{ range $pag.Pagers }} {{ $showNumber := or $showNumber (and (gt .PageNumber (sub $.paginator.PageNumber 3)) (lt .PageNumber (add $.paginator.PageNumber 3))) -}}
{{ $right := sub .TotalPages .PageNumber }} {{ if $showNumber -}}
{{ $showNumber := or (le .PageNumber 1) (eq $right 0) }} {{ $.Scratch.Set "paginator.ellipsed" false -}}
{{ $showNumber := or $showNumber (and (gt .PageNumber (sub $pag.PageNumber 3)) (lt .PageNumber (add $pag.PageNumber 3))) }} {{ $.Scratch.Set "paginator.shouldEllipse" false -}}
{{ if $showNumber }} {{ else -}}
{{ $.Scratch.Set "__paginator.ellipsed" false }} {{ $.Scratch.Set "paginator.shouldEllipse" (not ($.Scratch.Get "paginator.ellipsed") ) -}}
{{ $.Scratch.Set "__paginator.shouldEllipse" false }} {{ $.Scratch.Set "paginator.ellipsed" true -}}
{{ else }} {{ end -}}
{{ $.Scratch.Set "__paginator.shouldEllipse" (not ($.Scratch.Get "__paginator.ellipsed") ) }} {{ if $showNumber -}}
{{ $.Scratch.Set "__paginator.ellipsed" true }} <li class="page-item {{ if eq . $.paginator }}active{{ end }}">
{{ end }}
{{ if $showNumber }}
<li class="page-item {{ if eq . $pag }}active{{ end }}">
<span class="page-link"> <span class="page-link">
<a href="{{ .URL }}">{{ .PageNumber }}</a> <a href="{{ .URL }}">{{ .PageNumber }}</a>
</span> </span>
</li> </li>
{{ else if ($.Scratch.Get "__paginator.shouldEllipse") }} {{- else if ($.Scratch.Get "paginator.shouldEllipse") -}}
<li class="page-item "><span class="page-link" aria-hidden="true">&hellip;</span></li> <li class="page-item "><span class="page-link" aria-hidden="true">&hellip;</span></li>
{{ end }} {{ end -}}
{{ end }} {{ end -}}
</ul> </ul>
{{ end }} {{- end }}