Merge pull request #50 from rayjolt/i18n

Enable i18n
This commit is contained in:
Michael Romero 2017-04-09 22:32:42 -07:00 committed by GitHub
commit 5cf80fe2f7
15 changed files with 156 additions and 39 deletions

40
i18n/en.yaml Normal file
View File

@ -0,0 +1,40 @@
# Content
- id: dateFormat
translation: "January 2, 2006"
- id: postedOnDate
translation: "Posted on {{ .Count }}"
- id: translationsLabel
translation: "Other languages: "
- id: translationsSeparator
translation: ", "
- 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: languageSwitcherLabel
translation: "Language"
- id: gcseLabelShort
translation: "Search"
- id: gcseLabelLong
translation: "Search {{ .Site.Title }}"
- id: gcseClose
translation: "Close"

38
i18n/ja.yaml Normal file
View File

@ -0,0 +1,38 @@
# Content
- id: dateFormat
translation: "2006年1月2日"
- id: postedOnDate
translation: "{{ .Count }}に投稿"
- id: translationsLabel
translation: "翻訳:"
- id: translationsSeparator
translation: "・"
- 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

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

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="{{ .Lang }}">
{{ partial "head.html" . }}
@ -39,12 +39,12 @@
</a>
<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>
<div class="post-entry">
{{ if .Truncated }}
{{ .Summary }}
<a href="{{ .Permalink }}" class="post-read-more">[Read&nbsp;More]</a>
<a href="{{ .Permalink }}" class="post-read-more">[{{ i18n "readMore" }}]</a>
{{ else }}
{{ .Content }}
{{ end }}
@ -53,7 +53,7 @@
{{ if .Params.tags }}
<span class="post-meta">
{{ range .Params.tags }}
#<a href="/tags/{{ . | urlize }}">{{ . }}</a>&nbsp;
#<a href="{{ $.Site.LanguagePrefix }}/tags/{{ . | urlize }}">{{ . }}</a>&nbsp;
{{ end }}
</span>
{{ end }}

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="{{ .Lang }}">
{{ partial "head.html" . }}

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="{{ .Lang }}">
{{ partial "head.html" . }}
@ -14,7 +14,7 @@
<article class="post-preview">
<div class="list-group col-lg-4 col-lg-offset-4 col-md-6 col-md-offset-3">
{{ range $key, $value := .Data.Terms.ByCount }}
<a href="/{{ $data.Plural }}/{{ $value.Name | urlize }}" class="list-group-item">
<a href="{{ $.Site.LanguagePrefix }}/{{ $data.Plural }}/{{ $value.Name | urlize }}" class="list-group-item">
{{ $value.Name }}<span class="badge">{{ $value.Count }}</span></a>
{{ end }}
</div>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="{{ .Lang }}">
{{ partial "head.html" . }}
@ -30,13 +30,11 @@
{{ end }}
</a>
<p class="post-meta">
Posted on {{ .Date.Format (default "January 2, 2006" .Site.Params.dateFormat) }}
</p>
{{ partial "post_meta.html" . }}
<div class="post-entry">
{{ if .Truncated }}
{{ .Summary }}
<a href="{{ .Permalink }}" class="post-read-more">[Read&nbsp;More]</a>
<a href="{{ .Permalink }}" class="post-read-more">[{{ i18n "readMore" }}]</a>
{{ else }}
{{ .Content }}
{{ end }}
@ -45,7 +43,7 @@
{{ if .Params.tags }}
<span class="post-meta">
{{ range .Params.tags }}
#<a href="/tags/{{ . | urlize }}">{{ . }}</a>&nbsp;
#<a href="{{ $.Site.LanguagePrefix }}/tags/{{ . | urlize }}">{{ . }}</a>&nbsp;
{{ end }}
</span>
{{ end }}
@ -58,12 +56,12 @@
<ul class="pager main-pager">
{{ if .Paginator.HasPrev }}
<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>
{{ end }}
{{ if .Paginator.HasNext }}
<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>
{{ end }}
</ul>

View File

@ -17,7 +17,7 @@
{{ end }}
{{ if .Site.Params.rss }}
<li>
<a href="{{ .Site.BaseURL}}/index.xml" title="RSS">
<a href="{{ "/index.xml" | absLangURL }}" title="RSS">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-rss fa-stack-1x fa-inverse"></i>
@ -33,12 +33,12 @@
{{ if .Site.Title }}
&nbsp;&bull;&nbsp;
<a href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a>
<a href="{{ "/" | absLangURL }}">{{ .Site.Title }}</a>
{{ end }}
</p>
<!-- Please don't remove this, keep my open source work credited :) -->
<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 }}
</p>
</div>
@ -76,4 +76,4 @@
{{ end }}
{{ template "_internal/google_analytics.html" . }}
{{- partial "footer_custom.html" . }}
{{- partial "footer_custom.html" . }}

View File

@ -36,8 +36,8 @@
<!-- Hugo Version number -->
{{ .Hugo.Generator -}}
<!-- Links and stylesheets -->
<link rel="canonical" href="{{ .URL | absURL }}" />
<link rel="alternate" href="{{ "/index.xml" | absURL }}" type="application/rss+xml" title="{{ .Site.Title }}">
<link rel="canonical" href="{{ .URL | absLangURL }}" />
<link rel="alternate" href="{{ "/index.xml" | absLangURL }}" type="application/rss+xml" title="{{ .Site.Title }}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" integrity="sha384-wITovz90syo1dJWVh32uuETPVEtGigN07tkttEqPv+uR2SE/mbQcG7ATL28aI9H0" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

View File

@ -32,7 +32,7 @@
{{ end }}
{{ end }}
{{ if eq .Type "post" }}
<span class="post-meta">Posted on {{ .Date.Format (default "January 2, 2006" .Site.Params.dateFormat) }}</span>
{{ partial "post_meta.html" . }}
{{ end }}
</div>
</div>
@ -57,7 +57,7 @@
{{ end }}
{{ end }}
{{ if eq .Type "post" }}
<span class="post-meta">Posted on {{ .Date.Format (default "January 2, 2006" .Site.Params.dateFormat) }}</span>
{{ partial "post_meta.html" . }}
{{ end }}
</div>
</div>
@ -67,4 +67,4 @@
</header>
{{ else }}
<div class="intro-header"></div>
{{ end }}
{{ end }}

View File

@ -2,12 +2,12 @@
<div class="container-fluid">
<div class="navbar-header">
<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>
</button>
<a class="navbar-brand" href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a>
<a class="navbar-brand" href="{{ "/" | absLangURL }}">{{ .Site.Title }}</a>
</div>
<div class="collapse navbar-collapse" id="main-navbar">
@ -18,20 +18,44 @@
<a class="navlinks-parent" href="javascript:void(0)">{{ .Name }}</a>
<div class="navlinks-children">
{{ range .Children }}
<a href="{{ .URL }}">{{ .Name }}</a>
<a href="{{ .URL | relLangURL }}">{{ .Name }}</a>
{{ end }}
</div>
</li>
{{ else }}
<li>
<a title="{{ .Name }}" href="{{ .URL }}">{{ .Name }}</a>
<a title="{{ .Name }}" href="{{ .URL | relLangURL }}">{{ .Name }}</a>
</li>
{{ end }}
{{ end }}
{{ if .Site.IsMultiLingual }}
{{ if ge (len .Site.Languages) 3 }}
<li class="navlinks-container">
<a class="navlinks-parent" href="javascript:void(0)">{{ i18n "languageSwitcherLabel" }}</a>
<div class="navlinks-children">
{{ range .Site.Languages }}
{{ if not (eq .Lang $.Site.Language.Lang) }}
<a href="/{{ .Lang }}" lang="{{ .Lang }}">{{ default .Lang .LanguageName }}</a>
{{ end }}
{{ end }}
</div>
</li>
{{ else }}
<li>
{{ range .Site.Languages }}
{{ if not (eq .Lang $.Site.Language.Lang) }}
<a href="/{{ .Lang }}" lang="{{ .Lang }}">{{ default .Lang .LanguageName }}</a>
{{ end }}
{{ end }}
</li>
{{ end }}
{{ end }}
{{ if isset .Site.Params "gcse" }}
<li>
<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>
</li>
{{ end }}
@ -41,7 +65,7 @@
<div class="avatar-container">
<div class="avatar-img-border">
{{ if isset .Site.Params "logo" }}
<a title="{{ .Site.Title }}" href="{{ .Site.BaseURL }}">
<a title="{{ .Site.Title }}" href="{{ "/" | absLangURL }}">
<img class="avatar-img" src="{{ .Site.BaseURL }}/{{ .Site.Params.logo }}" alt="{{ .Site.Title }}" />
</a>
{{ end }}
@ -58,15 +82,15 @@
<div class="modal-content">
<div class="modal-header">
<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 class="modal-body">
<gcse:search></gcse:search>
</div>
<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>
{{ end }}
{{ end }}

View File

@ -8,12 +8,12 @@
<ul class="pager blog-pager">
{{ if .PrevInSection }}
<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>
{{ end }}
{{ if .NextInSection }}
<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>
{{ end }}
</ul>

View File

@ -0,0 +1,11 @@
<span class="post-meta">
{{ default (i18n "dateFormat") .Site.Params.dateformat | .Date.Format | i18n "postedOnDate" }}
{{ if .IsTranslated -}}
{{- $sortedTranslations := sort .Translations "Site.Language.Weight" -}}
{{- $links := apply $sortedTranslations "partial" "translation_link.html" "." -}}
{{- $cleanLinks := apply $links "chomp" "." -}}
{{- $linksOutput := delimit $cleanLinks (i18n "translationsSeparator") -}}
&nbsp;&bull;&nbsp; {{ i18n "translationsLabel" }}{{ $linksOutput }}
{{- end }}
</span>

View File

@ -0,0 +1,2 @@
<a href="{{ .Permalink }}" lang="{{ .Lang }}">{{ default .Lang .Site.Language.LanguageName }}</a>

View File

@ -337,6 +337,11 @@ footer .theme-by {
font-style: italic;
margin: 0 0 10px;
}
.post-preview .post-meta a,
.post-heading .post-meta a {
color: #404040;
text-decoration: none;
}
.post-preview .post-entry {
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
@ -694,4 +699,4 @@ td.gutter {
input.gsc-input, .gsc-input-box, .gsc-input-box-hover, .gsc-input-box-focus, .gsc-search-button {
box-sizing: content-box;
line-height: normal;
}
}