Skip to content

Commit

Permalink
feat(template): better post / page language support
Browse files Browse the repository at this point in the history
  • Loading branch information
sparanoid committed Aug 26, 2015
1 parent 5076db8 commit 6dd7a77
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
6 changes: 4 additions & 2 deletions _app/_includes/_amsf.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@
Page language tag
{% endcomment %}
{% capture amsf_page_lang %}
{% if page.lang %}
lang={{ page.lang }}
{% if page.languages and page.languages[0] != null %}
lang="{{ page.languages | first }}"
{% else %}
lang="{{ page.languages }}"
{% endif %}
{% endcapture %}

Expand Down
2 changes: 1 addition & 1 deletion _app/_includes/themes/curtana/includes/top.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>

{% if site.force_utf_8 %}
<meta charset=utf-8>
<meta charset="utf-8">
{% endif %}

<title>{{ amsf_page_title }}{{ amsf_site_title | strip }}</title>
Expand Down
4 changes: 2 additions & 2 deletions _app/_posts/note/2014-06-05-markup-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ Careful Skippy, you really aren’t as convincing as you think you are.

## Chinese Paragraph

「名词成灾」的流行病里,灾情最严重的该是所谓「科学至上」(scientism)。在现代的工业社会里,科学早成显贵,科技更是骄子,所以知识分子的口头与笔下,有意无意,总爱用一些「学术化」的抽象名词,好显得客观而精确。有人称之为「伪术语」(pseudo-jargon)。例如:明明是 first step,却要说成 initial phase:明明是 letter,却要说成 communication,都属此类。
<p lang="zh-cn">「名词成灾」的流行病里,灾情最严重的该是所谓「科学至上」(scientism)。在现代的工业社会里,科学早成显贵,科技更是骄子,所以知识分子的口头与笔下,有意无意,总爱用一些「学术化」的抽象名词,好显得客观而精确。有人称之为「伪术语」(pseudo-jargon)。例如:明明是 first step,却要说成 initial phase:明明是 letter,却要说成 communication,都属此类。</p>

## Japanese Paragraph

『雪国』の主な舞台は、上越国境の清水トンネルを抜けた湯沢温泉であるが、この作品も『伊豆の踊子』同様に、川端康成の旅の出会いから生まれたもので、雪中の火事も実際に起ったことだと川端は語っている。川端は作品内で故意に地名を隠しているが、1934 年(昭和 9 年)6 月 13 日より 1937 年まで新潟県湯沢町の高半旅館(現:高半ホテル)に逗留していたことを随筆『「雪国」の旅』で述べている。
<p lang="ja">『雪国』の主な舞台は、上越国境の清水トンネルを抜けた湯沢温泉であるが、この作品も『伊豆の踊子』同様に、川端康成の旅の出会いから生まれたもので、雪中の火事も実際に起ったことだと川端は語っている。川端は作品内で故意に地名を隠しているが、1934 年(昭和 9 年)6 月 13 日より 1937 年まで新潟県湯沢町の高半旅館(現:高半ホテル)に逗留していたことを随筆『「雪国」の旅』で述べている。</p>

```
## H2 Heading
Expand Down
37 changes: 36 additions & 1 deletion _app/_posts/note/2014-06-09-creating-themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,41 @@ Template:

There're some features can be integrated into your theme.

### (Basic) Multi-Language Support

You can define post / page language in your front-matter field:

```yaml
languages:
- zh-tw
```
An additional `lang` HTML attribute will be added to your final rendering:

```html
<article lang="zh-tw">
...
</article>
```

If your post / page content is multilingual, you can also define multiple languages in array:

```yaml
languages:
- zh-tw
- en-us
```

Please note that only the first item defined in `languages` array will be used in final `lang` ouput, the additional languages will be available in JSON feed output:

```json
{
"languages": ["zh-tw", "en-us"],
"categories": ["note"],
"tags": ["miscellaneous"]
}
```

### Smooshing Assets

For better performance, Almace Scaffolding will find all the CSS, script links and images in compiled HTML, and outputs a version with all the CSS, scripts and images (Base64) written inline. Sounds cool? but it needs theme support. Here's how:
Expand Down Expand Up @@ -254,7 +289,7 @@ This allow your user to be able to use Google Analytics for their site, tracking

```html
<!-- Google Analytics tracking code -->
{{ amsf_google_analytics }}
{% raw %}{{ amsf_google_analytics }}{% endraw %}
```

## Publishing Themes
Expand Down
4 changes: 2 additions & 2 deletions _app/assets/themes/curtana/_less/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,8 @@ body:hover .latest {
}

// Posts with Asian characters
[lang=zh],
[lang=ja] {
:lang(zh),
:lang(ja) {
text-align: justify;

header {
Expand Down

0 comments on commit 6dd7a77

Please sign in to comment.