Add basic support for multilingual site
Add language switcher on the top right of the site Switches taxonomies, article paths, home, etc. Every language is independent
This commit is contained in:
parent
2d6b0f8173
commit
e933a44125
2 changed files with 45 additions and 5 deletions
|
@ -58,7 +58,11 @@
|
|||
<div class="container">
|
||||
<div class="navbar-brand">
|
||||
{% if config.extra.zulma_brand %}
|
||||
{% if config.default_language is matching(lang) %}
|
||||
<a class="navbar-item" href="/">
|
||||
{% else %}
|
||||
<a class="navbar-item" href="{{"/" ~ lang ~ "/"}}">
|
||||
{% endif %}
|
||||
{% if config.extra.zulma_brand.image %}
|
||||
<img src="{{ config.extra.zulma_brand.image | safe | replace(from="$BASE_URL", to=config.base_url) }}"
|
||||
alt="{{ config.extra.zulma_brand.text }}">
|
||||
|
@ -77,11 +81,17 @@
|
|||
<div class="navbar-end">
|
||||
{% if config.extra.zulma_menu %}
|
||||
{% for item in config.extra.zulma_menu %}
|
||||
|
||||
{% if config.default_language is matching(lang) %}
|
||||
{% set item_url = item.url | replace(from="$BASE_URL", to=config.base_url) %}
|
||||
{% else %}
|
||||
{% set item_url = item.url | replace(from="$BASE_URL", to=config.base_url ~ "/" ~ lang) %}
|
||||
{% endif %}
|
||||
|
||||
{% set item_url = item_url ~ "/" %}
|
||||
<a itemprop="url"
|
||||
class="navbar-item {% if item_url == current_url %}is-active{% endif %}"
|
||||
href="{{ item.url | safe | replace(from="$BASE_URL", to=config.base_url) }}">
|
||||
href="{{ item_url }}">
|
||||
<span itemprop="name">{{ item.name }}
|
||||
</span>
|
||||
</a>
|
||||
|
@ -97,6 +107,36 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if config.languages %}
|
||||
{% if config.default_language is not matching(lang) %}
|
||||
{% set lang_url = current_url | replace(from=config.base_url ~ "/" ~ lang, to=config.base_url) %}
|
||||
<a itemprop="url"
|
||||
class="navbar-item {% if lang_url == current_url %}is-active{% endif %}"
|
||||
href="{{ lang_url }}">
|
||||
<span itemprop="name">{{ config.default_language }}
|
||||
</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% for available_lang in config.languages %}
|
||||
{% set lang_code = available_lang.code %}
|
||||
{% if lang_code is not matching(lang) %}
|
||||
|
||||
{% if lang is matching(config.default_language) %}
|
||||
{% set lang_url = current_url | replace(from=config.base_url ~ "/", to=config.base_url ~ "/" ~ lang_code ~ "/") %}
|
||||
{% else %}
|
||||
{% set lang_url = current_url | replace(from=config.base_url ~ "/" ~ lang, to=config.base_url ~ "/" ~ lang_code) %}
|
||||
{% endif %}
|
||||
<a itemprop="url"
|
||||
class="navbar-item {% if lang_url == current_url %}is-active{% endif %}"
|
||||
href="{{ lang_url }}">
|
||||
<span itemprop="name">{{ lang_code }}
|
||||
</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
{% if page.taxonomies.authors %}
|
||||
by
|
||||
{% for author in page.taxonomies.authors %}
|
||||
<a href="{{ get_taxonomy_url(kind="authors", name=author) | safe }}">
|
||||
<a href="{{ get_taxonomy_url(kind="authors", name=author, lang=page.lang) | safe }}">
|
||||
<span class="tag is-primary">{{ author }} </span>
|
||||
</a>
|
||||
{% if page.taxonomies.authors | length > 1 %}
|
||||
|
@ -113,7 +113,7 @@ and
|
|||
{% macro post_footer_categories(page) %}
|
||||
{% if page.taxonomies.categories %}
|
||||
{% set category = page.taxonomies.categories[0] %}
|
||||
in <a href="{{ get_taxonomy_url(kind="categories", name=category) | safe }}">
|
||||
in <a href="{{ get_taxonomy_url(kind="categories", name=category, lang=page.lang) | safe }}">
|
||||
<span class="tag is-success">
|
||||
{{ category }}
|
||||
</span>
|
||||
|
@ -126,7 +126,7 @@ in <a href="{{ get_taxonomy_url(kind="categories", name=category) | safe }}">
|
|||
{% if page.taxonomies.tags %}
|
||||
and tagged
|
||||
{% for tag in page.taxonomies.tags %}
|
||||
<a href="{{ get_taxonomy_url(kind="tags", name=tag) | safe }}">
|
||||
<a href="{{ get_taxonomy_url(kind="tags", name=tag, lang=page.lang) | safe }}">
|
||||
<span class="tag is-link">{{ tag }} </span>
|
||||
</a>
|
||||
{% if page.taxonomies.tags | length > 1 %}
|
||||
|
|
Loading…
Add table
Reference in a new issue