Skip to content

Commit

Permalink
feat: multi languages support traditional Chinese
Browse files Browse the repository at this point in the history
  • Loading branch information
kitian616 committed Nov 17, 2017
1 parent 9095e93 commit aeace5e
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 17 deletions.
2 changes: 1 addition & 1 deletion _config.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ nav_lists:
# repository_tree: e.g. master

## Language & timezone ##
lang: zh #the language of your site eg: zh, en
lang: en #the language of your site, eg: en(English), zh(简体中文), zh-Hans(简体中文), zh-Hant(繁體中文)
timezone: Asia/Shanghai

## Author & social ##
Expand Down
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ nav_lists:
# repository_tree: e.g. master

## Language & timezone ##
lang: en #the language of your site eg: zh, en
lang: en #the language of your site, eg: en(English), zh(简体中文), zh-Hans(简体中文), zh-Hant(繁體中文)
timezone: Asia/Shanghai

## Author & social ##
Expand Down
16 changes: 15 additions & 1 deletion _data/locale.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,42 @@
LINKS:
PAGES:
HOME:
en: Home
zh: 主页
zh-Hans: 主页
zh-Hant: 主頁
ALL:
en: All
zh: 归档
zh-Hans: 归档
zh-Hant: 歸檔
RSS:
en: RSS
zh: RSS
zh-Hans: RSS
zh-Hant: RSS

READMORE:
en: Click to read more ...
zh: 点我阅读更多...
zh-Hans: 点我阅读更多...
zh-Hant: 「點我閱讀更多」

COPYRIGHT_DATES: 2015 - 2017

LAST_UPDATED:
en: 'Last updated'
zh: '更新于'
zh-Hans: '更新于'
zh-Hant: '更新於'

ARTICLE_DATE_FORMAT:
en: '%b %d, %Y'
zh: '%Y年 %m月%d日'
zh-Hans: '%Y年 %m月%d日'
zh-Hant: '%Y年 %m月%d日'

ARTICLE_LIST_DATA_FORMAT:
en: '%b %d'
zh: '%m月%d日'
zh-Hans: '%m月%d日'
zh-Hant: '%m月%d日'
8 changes: 4 additions & 4 deletions _includes/blog/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
</div>
<nav>
<ul class="inline-list">
{% assign locale_link = site.data.locale.LINKS %}
{% assign locale_pages = site.data.locale.PAGES %}
<li><a href="{{ "/" | prepend: site.baseurl | replace: '//', '/' }}">
{% if locale_link.HOME[site.lang] %}{{ locale_link.HOME[site.lang] }}{% else %}{{ locale_link.HOME.en }}{% endif %}</a></li>
{% if locale_pages.HOME[site.lang] %}{{ locale_pages.HOME[site.lang] }}{% else %}{{ locale_pages.HOME.en }}{% endif %}</a></li>
<li><a href="{{ "/all.html" | prepend: site.baseurl | append: "?tag=" | replace: '//', '/'}}">
{% if locale_link.ALL[site.lang] %}{{ locale_link.ALL[site.lang] }}{% else %}{{ locale_link.ALL.en }}{% endif %}</a></li>
{% if locale_pages.ALL[site.lang] %}{{ locale_pages.ALL[site.lang] }}{% else %}{{ locale_pages.ALL.en }}{% endif %}</a></li>
{% for list in site.nav_lists %}
<li><a href="{{ list.url }}"> {{ list.title }} </a></li>
{% endfor %}
<li><a type="application/rss+xml" href="{{ "/feed.xml" | prepend: site.baseurl | replace: '//', '/'}}">
{% if locale_link.RSS[site.lang] %}{{ locale_link.RSS[site.lang] }}{% else %}{{ locale_link.RSS.en }}{% endif %}</a></li>
{% if locale_pages.RSS[site.lang] %}{{ locale_pages.RSS[site.lang] }}{% else %}{{ locale_pages.RSS.en }}{% endif %}</a></li>
</ul>
</nav>
</header>
4 changes: 3 additions & 1 deletion _includes/common-head.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<title>{% if page.title %}{{ page.title | truncatewords: 15 }} - {{ site.title }}{% else %}{{ site.title }}{% endif %}</title>
<title>{% if page.title or page.titles[site.lang] or page.titles.en %}
{% if page.title %}{{ page.title }}{% elsif page.titles[site.lang] %}{{ page.titles[site.lang] }}{% else %}{{ page.titles.en }}{% endif %} - {{ site.title }}
{% else %}{{ site.title }}{% endif %}</title>
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
<link rel="canonical" href="{% include snippets/page-url.html %}">
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{% include snippets/rss-url.html %}">
13 changes: 10 additions & 3 deletions _layouts/all.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
---
layout: blog-default
title: All Posts
titles:
en: All Pages
zh: 归档
zh-Hans: 归档
zh-Hant: 歸檔
---
<div class="m-all">
<div class="main">
<h1 class="js-page-heading">{{ page.title }}</h1>
<h1 class="js-page-heading">
{% if page.title %}{{ page.title }}{% elsif page.titles[site.lang] %}{{ page.titles[site.lang] }}{% else %}{{ page.titles.en }}{% endif %}
</h1>
{% include blog/tags.html %}
<!--group by year: http://stackoverflow.com/questions/19086284/jekyll-liquid-templating-how-to-group-blog-posts-by-year-->
<section class="js-year-wrapper">
Expand Down Expand Up @@ -72,7 +78,8 @@ <h2 class="year-title" id="year-{{ post.date | date: "%Y" }}">{{ currentdate }}<
var i = 0, flag = false, cur, tagStr = '',
tags = [], _tag = '', lis = [];
if (tag === undefined || tag === '') {
$pageHeading.text('{{ page.title }}'); $tagShowAll.focus(); $postBlock.show();
$pageHeading.text('{% if page.title %}{{ page.title }}{% elsif page.titles[site.lang] %}{{ page.titles[site.lang] }}{% else %}{{ page.titles.en }}{% endif %}');
$tagShowAll.focus(); $postBlock.show();
} else {
tag = tag.trim();
// $articleTag.filter('.tag-' + tag).focus();
Expand Down
6 changes: 5 additions & 1 deletion _layouts/home.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
---
layout: blog-default
title: Blog
titles:
en: Blog
zh: 博客
zh-Hans: 博客
zh-Hant: 博客
---
<div class="m-home">
<div class="main">
Expand Down
6 changes: 5 additions & 1 deletion all.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
layout: all
title: All Posts
titles:
en: All Pages
zh: 归档
zh-Hans: 归档
zh-Hant: 歸檔
---
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
layout: home
title: Blog
titles:
en: Blog
zh: 博客
zh-Hans: 博客
zh-Hant: 博客
---
2 changes: 1 addition & 1 deletion test/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ nav_lists:
# repository_tree: e.g. master

## Language & timezone ##
lang: en #the language of your site eg: zh, en
lang: en #the language of your site, eg: en(English), zh(简体中文), zh-Hans(简体中文), zh-Hant(繁體中文)
timezone: Asia/Shanghai

## Author & social ##
Expand Down
6 changes: 5 additions & 1 deletion test/all.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
layout: all
title: All Posts
titles:
en: All Pages
zh: 归档
zh-Hans: 归档
zh-Hant: 歸檔
---
6 changes: 5 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---
layout: home
title: Blog
titles:
en: Blog
zh: 博客
zh-Hans: 博客
zh-Hant: 博客
---

0 comments on commit aeace5e

Please sign in to comment.