Move hard-coded strings to i18n files

Add translations in English and in Japanese
This commit is contained in:
Jack Taylor 2017-04-02 18:58:27 +09:00
parent 1c26fe2526
commit 0f74f45531
9 changed files with 86 additions and 19 deletions

34
i18n/en.yaml Normal file
View File

@ -0,0 +1,34 @@
# Content
- id: dateFormat
translation: "January 2, 2006"
- id: postedOnDate
translation: "Posted on {{ .Count }}"
- id: readMore
translation: "Read More"
- id: olderPosts
translation: "Older Posts"
- id: newerPosts
translation: "Newer Posts"
- id: previousPost
translation: "Previous Post"
- id: nextPost
translation: "Next Post"
# 404 page
- id: pageNotFound
translation: "Whoops, this page doesn't exist. Move along. (404 error)"
# Footer
- id: poweredBy # Accepts HTML
translation: '<a href="http://gohugo.io">Hugo v{{ .Hugo.Version }}</a> powered &nbsp;&bull;&nbsp; Theme by <a href="http://deanattali.com/beautiful-jekyll/">Beautiful Jekyll</a> adapted to <a href="https://github.com/halogenica/beautifulhugo">Beautiful Hugo</a>'
# Navigation
- id: toggleNavigation
translation: "Toggle navigation"
- id: gcseLabelShort
translation: "Search"
- id: gcseLabelLong
translation: "Search {{ .Site.Title }}"
- id: gcseClose
translation: "Close"

34
i18n/ja.yaml Normal file
View File

@ -0,0 +1,34 @@
# Content
- id: dateFormat
translation: "2006年1月2日"
- id: postedOnDate
translation: "{{ .Count }}に投稿"
- id: readMore
translation: "続きを読む"
- id: olderPosts
translation: "古いページ"
- id: newerPosts
translation: "新しいページ"
- id: previousPost
translation: "前ページ"
- id: nextPost
translation: "次ページ"
# 404 page
- id: pageNotFound
translation: "おっと、このページが存在しない。他にあたってください。404エラー"
# Footer
- id: poweredBy # Accepts HTML
translation: '起動力に<a href="http://gohugo.io">Hugo v{{ .Hugo.Version }}</a> &nbsp;&bull;&nbsp; テーマに<a href="http://deanattali.com/beautiful-jekyll/">Beautiful Jekyll</a>に基づいている<a href="https://github.com/halogenica/beautifulhugo">Beautiful Hugo</a>'
# Navigation
- id: toggleNavigation
translation: "メニューを切り替え"
- id: gcseLabelShort
translation: "検索"
- id: gcseLabelLong
translation: "{{ .Site.Title }}を検索"
- id: gcseClose
translation: "閉じる"

View File

@ -9,8 +9,7 @@
<div role="main" class="container main-content"> <div role="main" class="container main-content">
<div class="text-center"> <div class="text-center">
<h1>Whoops, this page doesn't exist.</h1> <h1>{{ i18n "pageNotFound" }}</h1>
<h1>Move along. (404 error)</h1>
<br/> <br/>
<img src="{{ .Site.BaseURL }}/img/404-southpark.jpg" /> <img src="{{ .Site.BaseURL }}/img/404-southpark.jpg" />
</div> </div>

View File

@ -39,12 +39,12 @@
</a> </a>
<p class="post-meta"> <p class="post-meta">
Posted on {{ .Date.Format (default "January 2, 2006" .Site.Params.dateFormat) }} {{ default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format | i18n "postedOnDate" }}
</p> </p>
<div class="post-entry"> <div class="post-entry">
{{ if .Truncated }} {{ if .Truncated }}
{{ .Summary }} {{ .Summary }}
<a href="{{ .Permalink }}" class="post-read-more">[Read&nbsp;More]</a> <a href="{{ .Permalink }}" class="post-read-more">[{{ i18n "readMore" }}]</a>
{{ else }} {{ else }}
{{ .Content }} {{ .Content }}
{{ end }} {{ end }}

View File

@ -31,12 +31,12 @@
</a> </a>
<p class="post-meta"> <p class="post-meta">
Posted on {{ .Date.Format (default "January 2, 2006" .Site.Params.dateFormat) }} {{ default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format | i18n "postedOnDate" }}
</p> </p>
<div class="post-entry"> <div class="post-entry">
{{ if .Truncated }} {{ if .Truncated }}
{{ .Summary }} {{ .Summary }}
<a href="{{ .Permalink }}" class="post-read-more">[Read&nbsp;More]</a> <a href="{{ .Permalink }}" class="post-read-more">[{{ i18n "readMore" }}]</a>
{{ else }} {{ else }}
{{ .Content }} {{ .Content }}
{{ end }} {{ end }}
@ -58,12 +58,12 @@
<ul class="pager main-pager"> <ul class="pager main-pager">
{{ if .Paginator.HasPrev }} {{ if .Paginator.HasPrev }}
<li class="previous"> <li class="previous">
<a href="{{ .URL }}page/{{ .Paginator.Prev.PageNumber }}">&larr; Newer Posts</a> <a href="{{ .URL }}page/{{ .Paginator.Prev.PageNumber }}">&larr; {{ i18n "newerPosts" }}</a>
</li> </li>
{{ end }} {{ end }}
{{ if .Paginator.HasNext }} {{ if .Paginator.HasNext }}
<li class="next"> <li class="next">
<a href="{{ .URL }}page/{{ .Paginator.Next.PageNumber }}">Older Posts &rarr;</a> <a href="{{ .URL }}page/{{ .Paginator.Next.PageNumber }}">{{ i18n "olderPosts" }} &rarr;</a>
</li> </li>
{{ end }} {{ end }}
</ul> </ul>

View File

@ -38,7 +38,7 @@
</p> </p>
<!-- Please don't remove this, keep my open source work credited :) --> <!-- Please don't remove this, keep my open source work credited :) -->
<p class="credits theme-by text-muted"> <p class="credits theme-by text-muted">
<a href="http://gohugo.io">Hugo v{{ .Hugo.Version }}</a> powered &nbsp;&bull;&nbsp; Theme by <a href="http://deanattali.com/beautiful-jekyll/">Beautiful Jekyll</a> adapted to <a href="https://github.com/halogenica/beautifulhugo">Beautiful Hugo</a> {{ i18n "poweredBy" . | safeHTML }}
{{ with .Site.Params.commit }}&nbsp;&bull;&nbsp;[<a href="{{.}}{{ getenv "GIT_COMMIT_SHA" }}">{{ getenv "GIT_COMMIT_SHA_SHORT" }}</a>]{{ end }} {{ with .Site.Params.commit }}&nbsp;&bull;&nbsp;[<a href="{{.}}{{ getenv "GIT_COMMIT_SHA" }}">{{ getenv "GIT_COMMIT_SHA_SHORT" }}</a>]{{ end }}
</p> </p>
</div> </div>

View File

@ -32,7 +32,7 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if eq .Type "post" }} {{ if eq .Type "post" }}
<span class="post-meta">Posted on {{ .Date.Format (default "January 2, 2006" .Site.Params.dateFormat) }}</span> <span class="post-meta">{{ default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format | i18n "postedOnDate" }}</span>
{{ end }} {{ end }}
</div> </div>
</div> </div>
@ -57,7 +57,7 @@
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ if eq .Type "post" }} {{ if eq .Type "post" }}
<span class="post-meta">Posted on {{ .Date.Format (default "January 2, 2006" .Site.Params.dateFormat) }}</span> <span class="post-meta">{{ default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format | i18n "postedOnDate" }}</span>
{{ end }} {{ end }}
</div> </div>
</div> </div>

View File

@ -2,7 +2,7 @@
<div class="container-fluid"> <div class="container-fluid">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar">
<span class="sr-only">Toggle navigation</span> <span class="sr-only">{{ i18n "toggleNavigation" }}</span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
@ -31,7 +31,7 @@
{{ if isset .Site.Params "gcse" }} {{ if isset .Site.Params "gcse" }}
<li> <li>
<a href="#modalSearch" data-toggle="modal" data-target="#modalSearch" style="outline: none;"> <a href="#modalSearch" data-toggle="modal" data-target="#modalSearch" style="outline: none;">
<span class="hidden-sm hidden-md hidden-lg">Search</span> <span id="searchGlyph" class="glyphicon glyphicon-search"></span> <span class="hidden-sm hidden-md hidden-lg">{{ i18n "gcseLabelShort" }}</span> <span id="searchGlyph" class="glyphicon glyphicon-search"></span>
</a> </a>
</li> </li>
{{ end }} {{ end }}
@ -58,13 +58,13 @@
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button> <button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Search {{ .Site.Title }}</h4> <h4 class="modal-title">{{ i18n "gcseLabelLong" . }}</h4>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<gcse:search></gcse:search> <gcse:search></gcse:search>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-default" data-dismiss="modal">{{ i18n "gcseClose" }}</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -8,12 +8,12 @@
<ul class="pager blog-pager"> <ul class="pager blog-pager">
{{ if .PrevInSection }} {{ if .PrevInSection }}
<li class="previous"> <li class="previous">
<a href="{{ .PrevInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .PrevInSection.Title }}">&larr; Previous Post</a> <a href="{{ .PrevInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .PrevInSection.Title }}">&larr; {{ i18n "previousPost" }}</a>
</li> </li>
{{ end }} {{ end }}
{{ if .NextInSection }} {{ if .NextInSection }}
<li class="next"> <li class="next">
<a href="{{ .NextInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .NextInSection.Title }}">Next Post &rarr;</a> <a href="{{ .NextInSection.Permalink }}" data-toggle="tooltip" data-placement="top" title="{{ .NextInSection.Title }}">{{ i18n "nextPost" }} &rarr;</a>
</li> </li>
{{ end }} {{ end }}
</ul> </ul>