Store translations in config/theme extra
This commit is contained in:
parent
59447c810c
commit
e02a0c6a9d
|
@ -18,7 +18,7 @@
|
|||
{# TAXONOMY PROBLEM (not needed with Zola > 10.1) need to check if lang exists, do not display anything otherwise #}
|
||||
{% if lang %}
|
||||
{% if config.extra.header and config.extra.header != "disabled" %}{# TAXONOMY: no lang here #}
|
||||
{% set header = get_page(path=widgets::i18n_path(path=config.extra.header, lang=lang)) %}
|
||||
{% set header = get_page(path=widgets::i18n_path(path=config.extra.header)) %}
|
||||
{{ header.content | markdown | safe }}
|
||||
{% elif config.extra.header != "disabled" %}
|
||||
<h1>Welcome to water theme!</h1>
|
||||
|
@ -53,7 +53,7 @@
|
|||
{% set cur_path = section.relative_path|default(value=page.relative_path|default(value="")) %}
|
||||
{% if config.extra.forge and cur_path %}
|
||||
<aside class="source">
|
||||
{% set translated = trans(key="source", lang=lang) %}
|
||||
{% set translated = widgets::t(key="source") %}
|
||||
{% set browse_url = config.extra.forge.browse | trim_end_matches(pat="/") %}
|
||||
<a href="{{ browse_url }}/content/{{ cur_path }}">{{ translated }}</a>
|
||||
</aside>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div>
|
||||
<h1 class="p-name">{{ page.title }}</h1>
|
||||
<a class="u-url" hidden aria-hidden="true" href="{{ page.permalink }}">Permalink</a>
|
||||
{%- if page.date -%}<time class="dt-published" datetime="{{ page.date }}">📅 {{ page.date | date(format=trans(key="dateFormat", lang=lang)) }}</time>{%- endif -%}
|
||||
{%- if page.date -%}<time class="dt-published" datetime="{{ page.date }}">📅 {{ page.date | date(format=trans(key="dateFormat")) }}</time>{%- endif -%}
|
||||
</div>
|
||||
<div class="e-content">{{ page.content | safe }}</div>
|
||||
</article>
|
||||
|
|
|
@ -91,18 +91,18 @@ Separate entries with a thematic break:
|
|||
<a class="u-url" hidden aria-hidden=true href="{{ cur_section.permalink }}">Permalink</a>
|
||||
{% set pages = cur_paginator.pages| default(value=cur_section.pages) %}
|
||||
{% if pages|length < 1 %}
|
||||
<center><h2>{{ trans(key="nothing_yet", lang=lang) }}</h2></center>
|
||||
<center><h2>{{ self::t(key="nothing_yet") }}</h2></center>
|
||||
{% endif %}
|
||||
{% for page in pages %}
|
||||
<article>
|
||||
<div>
|
||||
<a class="u-url" href="{{ page.permalink }}"><h2>{{ page.title }}</h2></a>
|
||||
{%- if page.date -%}<time class="dt-published" datetime="{{ page.date }}">📅 {{ page.date | date(format=trans(key="dateFormat", lang=lang)) }}</time>{%- endif -%}
|
||||
{%- if page.date -%}<time class="dt-published" datetime="{{ page.date }}">📅 {{ page.date | date(format=self::t(key="dateFormat")) }}</time>{%- endif -%}
|
||||
</div>
|
||||
{% if page.summary %}
|
||||
<div class="p-summary e-content">
|
||||
{{ page.summary | markdown | safe }}
|
||||
<a class="read-more" href="{{ page.permalink }}">--> {{ trans(key="readmore", lang=lang) }} <--</a>
|
||||
<a class="read-more" href="{{ page.permalink }}">--> {{ self::t(key="readmore") }} <--</a>
|
||||
</div>
|
||||
{% elif full_articles %}
|
||||
<div class="e-content">
|
||||
|
@ -114,12 +114,19 @@ Separate entries with a thematic break:
|
|||
{% if cur_paginator and cur_paginator.number_pagers > 1 %}
|
||||
<aside class="pagination">
|
||||
{% if cur_paginator.previous %}
|
||||
<a href="{{ cur_paginator.previous }}"><-- {{ trans(key="previousPage", lang=lang) }}</a>
|
||||
<a href="{{ cur_paginator.previous }}"><-- {{ self::t(key="previousPage") }}</a>
|
||||
{% endif %}
|
||||
{% if cur_paginator.next %}
|
||||
<a href="{{ cur_paginator.next }}">{{ trans(key="nextPage", lang=lang) }} --></a>
|
||||
<a href="{{ cur_paginator.next }}">{{ self::t(key="nextPage") }} --></a>
|
||||
{% endif %}
|
||||
</aside>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endmacro section %}
|
||||
|
||||
{# Translate a string in the current language (lang) by looking
|
||||
up a key in the config.extra.translations.lang. These translation
|
||||
strings extend (and potentially replace) those of the theme. #}
|
||||
{%- macro t(key) -%}
|
||||
{{ config.extra.translations[lang][key] }}
|
||||
{%- endmacro t -%}
|
||||
|
|
|
@ -64,14 +64,14 @@ author = "kognise"
|
|||
homepage = "https://kognise.github.io/water.css/"
|
||||
repo = "https://github.com/kognise/water.css"
|
||||
|
||||
[translations.fr]
|
||||
[extra.translations.fr]
|
||||
source = "Source de cette page"
|
||||
readmore = "Lire la suite"
|
||||
previousPage = "Page précédente"
|
||||
nextPage = "Page suivante"
|
||||
dateFormat = "%d/%m/%Y"
|
||||
nothing_yet = "Il n'y a pas encore d'article dans cette section."
|
||||
[translations.en]
|
||||
[extra.translations.en]
|
||||
source = "Source for this page"
|
||||
readmore = "Read more"
|
||||
previousPage = "Previous page"
|
||||
|
|
Loading…
Reference in New Issue