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" baseurl = "https://example.com"
title = "Academic Theme" title = "Academic Theme"
copyright = "© 2016 Your Name" copyright = "© 2016 Your Name"
languageCode = "en-us"
theme = "academic" theme = "academic"
enableEmoji = true enableEmoji = true
footnotereturnlinkcontents = "<sup>^</sup>" footnotereturnlinkcontents = "<sup>^</sup>"
@ -12,6 +11,10 @@ disqusShortname = ""
# Enable analytics by entering your Google Analytics tracking ID # Enable analytics by entering your Google Analytics tracking ID
googleAnalytics = "" googleAnalytics = ""
# Default language to use (if you setup multilingual support)
defaultContentLanguage = "en"
defaultContentLanguageInSubdir = false
[blackfriday] [blackfriday]
hrefTargetBlank = true hrefTargetBlank = true
@ -119,3 +122,10 @@ googleAnalytics = ""
name = "Contact" name = "Contact"
url = "#contact" url = "#contact"
weight = 6 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. # List your academic interests.
[interests] [interests]
title = "Interests"
interests = [ interests = [
"Artificial Intelligence", "Artificial Intelligence",
"Computational Linguistics", "Computational Linguistics",
@ -19,9 +18,6 @@ weight = 0
] ]
# List your qualifications (such as academic degrees). # List your qualifications (such as academic degrees).
[education]
title = "Education"
[[education.courses]] [[education.courses]]
course = "PhD in Artificial Intelligence" course = "PhD in Artificial Intelligence"
institution = "Stanford University" institution = "Stanford University"

View file

@ -18,9 +18,5 @@ tags = []
# Number of posts to list. # Number of posts to list.
count = 5 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) # Show publication details (such as abstract)? (true/false)
detailed_list = 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"> <div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target=".navbar-collapse" aria-expanded="false"> 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> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -10,7 +10,7 @@
<h1 itemprop="name">{{ .Title }}</h1> <h1 itemprop="name">{{ .Title }}</h1>
{{ with .Params.external_link }} {{ 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 }} {{ end }}
<div class="article-style" itemprop="articleBody"> <div class="article-style" itemprop="articleBody">

View file

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

View file

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

View file

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

View file

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

View file

@ -20,7 +20,7 @@
{{end}} {{end}}
{{ if .Params.abstract }} {{ if .Params.abstract }}
<h3>Abstract</h3> <h3>{{ i18n "abstract" }}</h3>
<p class="pub-abstract" itemprop="text">{{ .Params.abstract }}</p> <p class="pub-abstract" itemprop="text">{{ .Params.abstract }}</p>
{{ else }} {{ else }}
<br> <br>
@ -30,7 +30,7 @@
<div class="col-sm-1"></div> <div class="col-sm-1"></div>
<div class="col-sm-10"> <div class="col-sm-10">
<div class="row"> <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 class="col-xs-12 col-sm-9">{{ .Params.event | markdownify }}</div>
</div> </div>
</div> </div>
@ -42,7 +42,7 @@
<div class="col-sm-1"></div> <div class="col-sm-1"></div>
<div class="col-sm-10"> <div class="col-sm-10">
<div class="row"> <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"> <div class="col-xs-12 col-sm-9" itemprop="datePublished">
{{ .Date.Format "January, 2006" }} {{ .Date.Format "January, 2006" }}
</div> </div>
@ -56,7 +56,7 @@
<div class="col-sm-1"></div> <div class="col-sm-1"></div>
<div class="col-sm-10"> <div class="col-sm-10">
<div class="row"> <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"> <div class="col-xs-12 col-sm-9">
{{ partial "publication_links" (dict "content" . "is_list" 0) }} {{ partial "publication_links" (dict "content" . "is_list" 0) }}