Skip to content

Commit

Permalink
feat: nav_lists multi languages - titles
Browse files Browse the repository at this point in the history
  • Loading branch information
kitian616 committed Nov 18, 2017
1 parent bb26897 commit c990c5a
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 21 deletions.
7 changes: 6 additions & 1 deletion _config.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ description: > #this means to ignore newlines until "nav_lists:"
Someone's Blog
nav_lists:
- title: About
# - title: About
- titles:
en: About
zh: 关于
zh-Hans: 关于
zh-Hant: 關於
url: /about.html

## GitHub repository (if the site is hosted by GitHub) ##
Expand Down
14 changes: 10 additions & 4 deletions _data/locale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ READMORE:
COPYRIGHT_DATES: 2015 - 2017

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

ARTICLE_DATE_FORMAT:
en: '%b %d, %Y'
Expand All @@ -41,6 +41,12 @@ ARTICLE_LIST_DATA_FORMAT:
zh-Hans: '%m月%d日'
zh-Hant: '%m月%d日'

STATISTICS:
en: '[post_count] post articles, [page_count] pages.'
zh: 共计 [post_count] 篇文章, [page_count] 页。
zh-Hans: 共计 [post_count] 篇文章, [page_count] 页。
zh-Hant: 共計 [post_count] 篇文章, [page_count] 頁。

LICENSE_ANNOUNCE:
en: This work is licensed under a [LICENSE] license.
zh: 本文遵守 [LICENSE] 许可协议。
Expand Down
10 changes: 6 additions & 4 deletions _includes/blog/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
<ul class="inline-list">
{% assign __locale = site.data.locale.PAGES.HOME %}
{% include snippets/locale-to-string.html %}
<li><a href="{{ "/" | prepend: site.baseurl | replace: '//', '/' }}">{{ __return }}</a></li>
<li><a href="{{ '/' | prepend: site.baseurl | replace: '//', '/' }}">{{ __return }}</a></li>
{% assign __locale = site.data.locale.PAGES.ALL %}
{% include snippets/locale-to-string.html %}
<li><a href="{{ "/all.html" | prepend: site.baseurl | append: "?tag=" | replace: '//', '/'}}">{{ __return }}</a></li>
<li><a href="{{ '/all.html' | prepend: site.baseurl | append: "?tag=" | replace: '//', '/'}}">{{ __return }}</a></li>
{% for list in site.nav_lists %}
<li><a href="{{ list.url }}"> {{ list.title }} </a></li>
{% assign __locale = list.titles %}
{% include snippets/locale-to-string.html %}
<li><a href="{{ list.url }}">{% if list.title %}{{ list.title }}{% else %}{{ __return }}{% endif %}</a></li>
{% endfor %}
{% assign __locale = site.data.locale.PAGES.RSS %}
{% include snippets/locale-to-string.html %}
<li><a type="application/rss+xml" href="{{ "/feed.xml" | prepend: site.baseurl | replace: '//', '/'}}">{{ __return }}</a></li>
<li><a type="application/rss+xml" href="{{ '/feed.xml' | prepend: site.baseurl | replace: '//', '/'}}">{{ __return }}</a></li>
</ul>
</nav>
</header>
5 changes: 2 additions & 3 deletions _includes/common-head.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<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 or page.titles[site.lang] or page.titles.en %}
{% include snippets/page-title.html %} - {{ site.title }}
{% else %}{{ site.title }}{% endif %}</title>
{% include snippets/page-title.html %}
<title>{% if __return %}{{ __return }} - {{ 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 %}">
7 changes: 6 additions & 1 deletion _includes/snippets/page-title.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{% assign __locale = page.titles %}
{% include snippets/locale-to-string.html %}
{% if page.title %}{{ page.title }}{% else %}{{ __return }}{% endif %}
{% assign __localeTitle = __return %}
{% if page.title %}
{% assign __return = page.title %}
{% else %}
{% assign __return = __localeTitle %}
{% endif %}
9 changes: 4 additions & 5 deletions _layouts/all.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
---
<div class="m-all">
<div class="main">
<h1 class="js-page-heading">
{% include snippets/page-title.html %}
</h1>
{% include snippets/page-title.html %}
<h1 class="js-page-heading">{{ __return }}</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 @@ -41,7 +40,7 @@ <h2 class="year-title" id="year-{{ post.date | date: "%Y" }}">{{ currentdate }}<
</section>
</div>
</div>

{% include snippets/page-title.html %}
<script type="text/javascript">
// function queryString is copied from
// http://stackoverflow.com/questions/979975/how-to-get-the-value-from-url-parameter#answer-979995
Expand Down Expand Up @@ -78,7 +77,7 @@ <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('{% include snippets/page-title.html %}');
$pageHeading.text('{{ __return }}');
$tagShowAll.focus(); $postBlock.show();
} else {
tag = tag.trim();
Expand Down
6 changes: 5 additions & 1 deletion _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ <h1>
</div>
{% if paginator.total_pages > 1 %}
<nav class="m-pagination">
<p>{{ site.posts | size }} post articles, {{ paginator.total_pages }} pages.</p>
{% assign __locale = site.data.locale.STATISTICS %}
{% include snippets/locale-to-string.html %}
{% assign post_count = site.posts | size %}
{% assign page_count = paginator.total_pages %}
<p>{{ __return | replace: '[post_count]', post_count | replace: '[page_count]', page_count }}</p>
<ul class="inline-list">
{% if paginator.previous_page %}
<li><a class="round-button" href="{{ paginator.previous_page_path | prepend: site.baseurl | replace: '//', '/' }}">
Expand Down
3 changes: 2 additions & 1 deletion _layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
---
<div class="m-page">
<article class="main">
<h1>{% include snippets/page-title.html %}</h1>
{% include snippets/page-title.html %}
<h1>{{ __return }}</h1>

<div class="m-article-content" itemprop="articleBody">
{{ content }}
Expand Down
3 changes: 2 additions & 1 deletion _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<article itemscope itemtype="http://schema.org/BlogPosting">
<meta itemprop="mainEntityOfPage" itemscope itemType="https://schema.org/WebPage"/>
<header class="article-header">
<h1 itemprop="headline" itemprop="name headline">{% include snippets/page-title.html %}</h1>
{% include snippets/page-title.html %}
<h1 itemprop="headline" itemprop="name headline">{{ __return }}</h1>
{% include blog/article-data.html %}
</header>
<div class="m-article-content js-article-content" itemprop="articleBody">
Expand Down

0 comments on commit c990c5a

Please sign in to comment.