2017-03-12 4 views
-1

私はジキルを初めて、私は現在スペイン語で書かれたブログを始めています。私はXML時間スキーマをスペイン語の文字列に変換したい。 "2017年1月1日更新"の代わりに、 "Actualizado el 01 de enero de 2017"または類似のものが必要です。 date_to_stringを私のニーズに合うものに変換する方法はありますか?ありがとう。`date_to_string`は別の言語ですか?

答えて

1

現時点では、これを行うことができるジキルには何もありません。あなたはあなたの言語で月の名前などを取得するために少しのコードを書く必要があります。ここで

は一例です:

<!-- Whitespace added for readability --> 
{% assign m = page.date | date: "%-m" %} 
{{ page.date | date: "%-d" }} 
{% case m %} 
    {% when '1' %}Januar 
    {% when '2' %}Februar 
    {% when '3' %}M&auml;rz 
    {% when '4' %}April 
    {% when '5' %}Mai 
    {% when '6' %}Juni 
    {% when '7' %}Juli 
    {% when '8' %}August 
    {% when '9' %}September 
    {% when '10' %}Oktober 
    {% when '11' %}November 
    {% when '12' %}Dezember 
{% endcase %} 
{{ page.date | date: "%Y" }} 

あなたがここにジキルと書式設定日に他の多くの例を見ることができます: http://alanwsmith.com/jekyll-liquid-date-formatting-examples

0

あなたは、私はそれを考えて、複数の言語を要求しませんでしたがそれをここに追加すると良いでしょう。以下は

_includes/date.htmlなど、私は記事をブログに複数の言語を追加する方法である:

{% capture hide %} 

{% if include.mode != 'month' %} 

    {% assign day = include.date | date: "%-d" %} 

{% endif %} 

{% if page.language == 'th' %} 

    {% assign m = include.date | date: "%-m" %} 
    {% case m %} 
    {% when '1' %} 
     {% capture month %}มกราคม{% endcapture %} 
    {% when '2' %} 
     {% capture month %}กุมภาพันธ์{% endcapture %} 
    {% when '3' %} 
     {% capture month %}มีนาคม{% endcapture %} 
    {% when '4' %} 
     {% capture month %}เมษายน{% endcapture %} 
    {% when '5' %} 
     {% capture month %}พฤษภาคม{% endcapture %} 
    {% when '6' %} 
     {% capture month %}มิถุนายน{% endcapture %} 
    {% when '7' %} 
     {% capture month %}กรกฎาคม{% endcapture %} 
    {% when '8' %} 
     {% capture month %}สิงหาคม{% endcapture %} 
    {% when '9' %} 
     {% capture month %}กันยายน{% endcapture %} 
    {% when '10' %} 
     {% capture month %}ตุลาคม{% endcapture %} 
    {% when '11' %} 
     {% capture month %}พฤศจิกายน{% endcapture %} 
    {% when '12' %} 
     {% capture month %}ธันวาคม{% endcapture %} 
    {% endcase %} 

{% else %} 

    {% capture month %}{{ include.date | date: "%B" }}{% endcapture %} 

{% endif %} 

{% capture year %}{{ include.date | date: "%Y" }}{% endcapture %} 

{% endcapture %} 

_includes /ポストtime.html:

{% include date.html date=post.date %} 

<time class="entry-time" itemprop="datePublished" datetime="{{ post.date | date_to_xmlschema }}">{% if page.language == 'th' %}{{ day }} {{ month }} {{ year }}{% else %}{{ month }} {{ day }}, {{ year }}{% endif %}</time> 

その後、私は{% include post-time.html %}を使用することができます上記のHTML出力が必要な場所であればどこでも。

3言語が必要な場合は、_includes/date.htmlファイルに条件付きを追加することもできます。

関連する問題