Add internationalization (i18n) support (#12)

This commit is contained in:
George Cushen 2016-12-19 06:01:11 +00:00
commit 31f9ce5f94
19 changed files with 133 additions and 48 deletions

View file

@ -1,7 +1,6 @@
baseurl = "https://example.com"
title = "Academic Theme"
copyright = "© 2016 Your Name"
languageCode = "en-us"
theme = "academic"
enableEmoji = true
footnotereturnlinkcontents = "<sup>^</sup>"
@ -12,6 +11,10 @@ disqusShortname = ""
# Enable analytics by entering your Google Analytics tracking ID
googleAnalytics = ""
# Default language to use (if you setup multilingual support)
defaultContentLanguage = "en"
defaultContentLanguageInSubdir = false
[blackfriday]
hrefTargetBlank = true
@ -119,3 +122,10 @@ googleAnalytics = ""
name = "Contact"
url = "#contact"
weight = 6
# Languages
# Create a [languages.X] block for each language you want, where X is the language ID.
# Configure the English version of the website.
[languages.en]
languageCode = "en-us"

View file

@ -11,7 +11,6 @@ weight = 0
# List your academic interests.
[interests]
title = "Interests"
interests = [
"Artificial Intelligence",
"Computational Linguistics",
@ -19,9 +18,6 @@ weight = 0
]
# List your qualifications (such as academic degrees).
[education]
title = "Education"
[[education.courses]]
course = "PhD in Artificial Intelligence"
institution = "Stanford University"

View file

@ -18,9 +18,5 @@ tags = []
# Number of posts to list.
count = 5
# Links.
str_all = "More Posts"
str_read_more = "CONTINUE READING"
+++

View file

@ -18,8 +18,5 @@ count = 10
# Show publication details (such as abstract)? (true/false)
detailed_list = false
# Link.
str_all = "More Publications"
+++

86
i18n/en.yaml Normal file
View file

@ -0,0 +1,86 @@
# Navigation
- id: toggle_navigation
translation: Toggle navigation
# Buttons
- id: btn_details
translation: Details
- id: btn_pdf
translation: PDF
- id: btn_slides
translation: Slides
- id: btn_video
translation: Video
- id: btn_code
translation: Code
- id: btn_dataset
translation: Dataset
- id: btn_project
translation: Project
# About widget
- id: interests
translation: Interests
- id: education
translation: Education
# Publications widget
- id: more_publications
translation: More Publications
# Posts widget
- id: continue_reading
translation: CONTINUE READING
- id: more_posts
translation: More Posts
# Talks widget
- id: more_talks
translation: More Talks
# Publication/Talk details
- id: abstract
translation: Abstract
- id: publication
translation: Publication
- id: date
translation: Date
- id: links
translation: Links
- id: event
translation: Event
# Project details
- id: open_project_site
translation: Go to Project Site
# Section titles
- id: posts
translation: Posts
- id: publications
translation: Publications
- id: talks
translation: Talks

View file

@ -5,7 +5,7 @@
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target=".navbar-collapse" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="sr-only">{{ i18n "toggle_navigation" }}</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>

View file

@ -23,7 +23,7 @@
</div>
<p class="read-more">
<a href="{{ $post.Permalink }}" class="btn btn-primary btn-outline">
{{ with $page.Params.str_read_more }}{{ . | markdownify }}{{ end }}
{{ i18n "continue_reading" }}
</a>
</p>
</div>

View file

@ -3,37 +3,37 @@
{{ if $is_list }}
<a class="btn btn-primary btn-outline btn-xs" href="{{ $.Permalink }}">
Details
{{ i18n "btn_details" }}
</a>
{{ end }}
{{ with $.Params.url_pdf }}
<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
PDF
{{ i18n "btn_pdf" }}
</a>
{{ end }}
{{ with $.Params.url_slides }}
<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
Slides
{{ i18n "btn_slides" }}
</a>
{{ end }}
{{ with $.Params.url_video }}
<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
Video
{{ i18n "btn_video" }}
</a>
{{ end }}
{{ with $.Params.url_code }}
<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
Code
{{ i18n "btn_code" }}
</a>
{{ end }}
{{ with $.Params.url_dataset }}
<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
Dataset
{{ i18n "btn_dataset" }}
</a>
{{ end }}
{{ with $.Params.url_project }}
<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
Project
{{ i18n "btn_project" }}
</a>
{{ end }}
{{ range $.Params.url_custom }}

View file

@ -3,22 +3,22 @@
{{ if $is_list }}
<a class="btn btn-primary btn-outline btn-xs" href="{{ $.Permalink }}">
Details
{{ i18n "btn_details" }}
</a>
{{ end }}
{{ with $.Params.url_pdf }}
<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
PDF
{{ i18n "btn_pdf" }}
</a>
{{ end }}
{{ with $.Params.url_slides }}
<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
Slides
{{ i18n "btn_slides" }}
</a>
{{ end }}
{{ with $.Params.url_video }}
<a class="btn btn-primary btn-outline{{ if $is_list }} btn-xs{{end}}" href="{{ . | absURL }}">
Video
{{ i18n "btn_video" }}
</a>
{{ end }}
{{ range $.Params.url_custom }}

View file

@ -39,7 +39,7 @@
{{ with $page.Params.interests }}
<div class="col-sm-5">
<h3>{{ .title | default "Interests" | markdownify }}</h3>
<h3>{{ i18n "interests" | markdownify }}</h3>
<ul class="ul-interests">
{{ range .interests }}
<li>{{ . }}</li>
@ -50,7 +50,7 @@
{{ with $page.Params.education }}
<div class="col-sm-7">
<h3>{{ .title | default "Education" | markdownify }}</h3>
<h3>{{ i18n "education" | markdownify }}</h3>
<ul class="ul-edu fa-ul">
{{ range .courses }}
<li>

View file

@ -11,7 +11,7 @@
{{ if gt $posts_len $page.Params.count }}
<p class="view-all">
<a href="{{ "/post/" | relURL }}">
{{ with $page.Params.str_all }}{{ . | markdownify }}{{ end }}
{{ i18n "more_posts" | markdownify }}
<i class="fa fa-angle-double-right"></i>
</a>
</p>

View file

@ -10,7 +10,7 @@
{{ if gt $pubs_len $page.Params.count }}
<p class="view-all">
<a href="{{ $.Site.BaseURL }}publication/">
{{ with $page.Params.str_all }}{{ . | markdownify }}{{ end }}
{{ i18n "more_publications" | markdownify }}
<i class="fa fa-angle-double-right"></i>
</a>
</p>

View file

@ -10,7 +10,7 @@
{{ if gt $talks_len $page.Params.count }}
<p class="view-all">
<a href="{{ $.Site.BaseURL }}talk/">
{{ with $page.Params.str_all }}{{ . | markdownify }}{{ end }}
{{ i18n "more_talks" | markdownify }}
<i class="fa fa-angle-double-right"></i>
</a>
</p>

View file

@ -10,7 +10,7 @@
<h1 itemprop="name">{{ .Title }}</h1>
{{ with .Params.external_link }}
<a class="btn btn-primary btn-outline" href="{{ . }}">Go to Project Site</a>
<a class="btn btn-primary btn-outline" href="{{ . }}">{{ i18n "open_project_site" }}</a>
{{ end }}
<div class="article-style" itemprop="articleBody">

View file

@ -6,27 +6,27 @@
<div class="pub-title">
<h1 itemprop="name">{{ .Title }}</h1>
<span class="pub-authors" itemprop="author">
{{ with .Params.authors }}
{{ delimit . ", " }}
{{ end }}
</span>
{{ with .Params.authors }}
{{ delimit . ", " }}
{{ end }}
</span>
<span class="pull-right">
{{ partial "share.html" . }}
</span>
{{ partial "share.html" . }}
</span>
</div>
{{ if .Params.image }}
<img src="{{ $.Site.BaseURL }}img/{{ .Params.image }}" class="pub-banner" itemprop="image">
{{end}}
<h3>Abstract</h3>
<h3>{{ i18n "abstract" }}</h3>
<p class="pub-abstract" itemprop="text">{{ .Params.abstract }}</p>
<div class="row">
<div class="col-sm-1"></div>
<div class="col-sm-10">
<div class="row">
<div class="col-xs-12 col-sm-3 pub-row-heading">Publication</div>
<div class="col-xs-12 col-sm-3 pub-row-heading">{{ i18n "publication" }}</div>
<div class="col-xs-12 col-sm-9">{{ .Params.publication | markdownify }}</div>
</div>
</div>
@ -38,7 +38,7 @@
<div class="col-sm-1"></div>
<div class="col-sm-10">
<div class="row">
<div class="col-xs-12 col-sm-3 pub-row-heading">Date</div>
<div class="col-xs-12 col-sm-3 pub-row-heading">{{ i18n "date" }}</div>
<div class="col-xs-12 col-sm-9" itemprop="datePublished">
{{ .Date.Format "January, 2006" }}
</div>
@ -52,7 +52,7 @@
<div class="col-sm-1"></div>
<div class="col-sm-10">
<div class="row">
<div class="col-xs-12 col-sm-3 pub-row-heading" style="line-height:34px;">Links</div>
<div class="col-xs-12 col-sm-3 pub-row-heading" style="line-height:34px;">{{ i18n "links" }}</div>
<div class="col-xs-12 col-sm-9">
{{ partial "publication_links" (dict "content" . "is_list" 0) }}

View file

@ -2,7 +2,7 @@
{{ partial "navbar.html" . }}
<div class="container">
<h1>Posts</h1>
<h1>{{ i18n "posts" }}</h1>
{{ $paginator := .Paginate .Data.Pages }}
{{ range $paginator.Pages }}

View file

@ -3,7 +3,7 @@
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>Publications</h1>
<h1>{{ i18n "publications" }}</h1>
{{ range .Data.Pages.GroupByDate "2006" }}
<div class="row" id="pub_list">

View file

@ -3,7 +3,7 @@
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>Talks</h1>
<h1>{{ i18n "talks" }}</h1>
{{ range .Data.Pages.GroupByDate "2006" }}
<div class="row" id="talk_list">

View file

@ -20,7 +20,7 @@
{{end}}
{{ if .Params.abstract }}
<h3>Abstract</h3>
<h3>{{ i18n "abstract" }}</h3>
<p class="pub-abstract" itemprop="text">{{ .Params.abstract }}</p>
{{ else }}
<br>
@ -30,7 +30,7 @@
<div class="col-sm-1"></div>
<div class="col-sm-10">
<div class="row">
<div class="col-xs-12 col-sm-3 pub-row-heading">Event</div>
<div class="col-xs-12 col-sm-3 pub-row-heading">{{ i18n "event" }}</div>
<div class="col-xs-12 col-sm-9">{{ .Params.event | markdownify }}</div>
</div>
</div>
@ -42,7 +42,7 @@
<div class="col-sm-1"></div>
<div class="col-sm-10">
<div class="row">
<div class="col-xs-12 col-sm-3 pub-row-heading">Date</div>
<div class="col-xs-12 col-sm-3 pub-row-heading">{{ i18n "date" }}</div>
<div class="col-xs-12 col-sm-9" itemprop="datePublished">
{{ .Date.Format "January, 2006" }}
</div>
@ -56,7 +56,7 @@
<div class="col-sm-1"></div>
<div class="col-sm-10">
<div class="row">
<div class="col-xs-12 col-sm-3 pub-row-heading" style="line-height:34px;">Links</div>
<div class="col-xs-12 col-sm-3 pub-row-heading" style="line-height:34px;">{{ i18n "links" }}</div>
<div class="col-xs-12 col-sm-9">
{{ partial "publication_links" (dict "content" . "is_list" 0) }}