From 31f9ce5f943a5e4f7ff2773f980b73d422c241f2 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Mon, 19 Dec 2016 06:01:11 +0000 Subject: [PATCH] Add internationalization (i18n) support (#12) --- exampleSite/config.toml | 12 ++- exampleSite/content/home/about.md | 4 - exampleSite/content/home/posts.md | 4 - exampleSite/content/home/publications.md | 3 - i18n/en.yaml | 86 ++++++++++++++++++++++ layouts/partials/navbar.html | 2 +- layouts/partials/post_li.html | 2 +- layouts/partials/publication_links.html | 14 ++-- layouts/partials/talk_links.html | 8 +- layouts/partials/widgets/about.html | 4 +- layouts/partials/widgets/posts.html | 2 +- layouts/partials/widgets/publications.html | 2 +- layouts/partials/widgets/talks.html | 2 +- layouts/project/single.html | 2 +- layouts/publication/single.html | 20 ++--- layouts/section/post.html | 2 +- layouts/section/publication.html | 2 +- layouts/section/talk.html | 2 +- layouts/talk/single.html | 8 +- 19 files changed, 133 insertions(+), 48 deletions(-) create mode 100644 i18n/en.yaml diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 6c0b5ba3..a22440a6 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -1,7 +1,6 @@ baseurl = "https://example.com" title = "Academic Theme" copyright = "© 2016 Your Name" -languageCode = "en-us" theme = "academic" enableEmoji = true footnotereturnlinkcontents = "^" @@ -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" diff --git a/exampleSite/content/home/about.md b/exampleSite/content/home/about.md index 4923336c..21aa1b18 100644 --- a/exampleSite/content/home/about.md +++ b/exampleSite/content/home/about.md @@ -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" diff --git a/exampleSite/content/home/posts.md b/exampleSite/content/home/posts.md index 12ff6f2b..bbbaa638 100644 --- a/exampleSite/content/home/posts.md +++ b/exampleSite/content/home/posts.md @@ -18,9 +18,5 @@ tags = [] # Number of posts to list. count = 5 -# Links. -str_all = "More Posts" -str_read_more = "CONTINUE READING" - +++ diff --git a/exampleSite/content/home/publications.md b/exampleSite/content/home/publications.md index ed445a61..915cf71b 100644 --- a/exampleSite/content/home/publications.md +++ b/exampleSite/content/home/publications.md @@ -18,8 +18,5 @@ count = 10 # Show publication details (such as abstract)? (true/false) detailed_list = false -# Link. -str_all = "More Publications" - +++ diff --git a/i18n/en.yaml b/i18n/en.yaml new file mode 100644 index 00000000..29b6bedd --- /dev/null +++ b/i18n/en.yaml @@ -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 diff --git a/layouts/partials/navbar.html b/layouts/partials/navbar.html index a358bb67..3c02faff 100644 --- a/layouts/partials/navbar.html +++ b/layouts/partials/navbar.html @@ -5,7 +5,7 @@

- {{ with $page.Params.str_read_more }}{{ . | markdownify }}{{ end }} + {{ i18n "continue_reading" }}

diff --git a/layouts/partials/publication_links.html b/layouts/partials/publication_links.html index 912bd186..c8dad3bf 100644 --- a/layouts/partials/publication_links.html +++ b/layouts/partials/publication_links.html @@ -3,37 +3,37 @@ {{ if $is_list }} - Details + {{ i18n "btn_details" }} {{ end }} {{ with $.Params.url_pdf }} - PDF + {{ i18n "btn_pdf" }} {{ end }} {{ with $.Params.url_slides }} - Slides + {{ i18n "btn_slides" }} {{ end }} {{ with $.Params.url_video }} - Video + {{ i18n "btn_video" }} {{ end }} {{ with $.Params.url_code }} - Code + {{ i18n "btn_code" }} {{ end }} {{ with $.Params.url_dataset }} - Dataset + {{ i18n "btn_dataset" }} {{ end }} {{ with $.Params.url_project }} - Project + {{ i18n "btn_project" }} {{ end }} {{ range $.Params.url_custom }} diff --git a/layouts/partials/talk_links.html b/layouts/partials/talk_links.html index 3386c87f..246d6b2c 100644 --- a/layouts/partials/talk_links.html +++ b/layouts/partials/talk_links.html @@ -3,22 +3,22 @@ {{ if $is_list }} - Details + {{ i18n "btn_details" }} {{ end }} {{ with $.Params.url_pdf }} - PDF + {{ i18n "btn_pdf" }} {{ end }} {{ with $.Params.url_slides }} - Slides + {{ i18n "btn_slides" }} {{ end }} {{ with $.Params.url_video }} - Video + {{ i18n "btn_video" }} {{ end }} {{ range $.Params.url_custom }} diff --git a/layouts/partials/widgets/about.html b/layouts/partials/widgets/about.html index 97cd5ca5..29197e79 100644 --- a/layouts/partials/widgets/about.html +++ b/layouts/partials/widgets/about.html @@ -39,7 +39,7 @@ {{ with $page.Params.interests }}
-

{{ .title | default "Interests" | markdownify }}

+

{{ i18n "interests" | markdownify }}