mirror of
https://github.com/Speyll/anemone.git
synced 2024-12-25 10:36:32 +00:00
streamlined how multilingual support works
This commit is contained in:
parent
ccbee0ef42
commit
ed97e270b8
5 changed files with 42 additions and 81 deletions
33
README.md
33
README.md
|
@ -53,23 +53,11 @@ list_pages = true
|
|||
The theme has a built-in feature that allows you to use multiple languages. For detailed instructions on how to use this feature, you can refer to the [Zola Multilingual documentation](https://www.getzola.org/documentation/content/multilingual/). This documentation provides additional information on how to make the most out of this multilingual capability.
|
||||
|
||||
```toml
|
||||
[languages.en]
|
||||
weight = 1
|
||||
title = "anemone"
|
||||
languageName = "English"
|
||||
languageCode = "en"
|
||||
relativeURL = false
|
||||
|
||||
[languages.fr]
|
||||
weight = 2
|
||||
title = "anemone"
|
||||
languageName = "Français"
|
||||
languageCode = "fr"
|
||||
relativeURL = false
|
||||
|
||||
taxonomies = [
|
||||
{name = "tags", feed = true},
|
||||
]
|
||||
```
|
||||
#### Multilanguage-Ready Navigation Bar
|
||||
|
||||
|
@ -78,21 +66,12 @@ Customize the header navigation links with the following code in the `extra` sec
|
|||
```toml
|
||||
[extra]
|
||||
|
||||
[[extra.header_nav]]
|
||||
en = { name = "/home/", url = "/" }
|
||||
fr = { name = "/accueil/", url = "/fr" }
|
||||
|
||||
[[extra.header_nav]]
|
||||
en = { name = "/about/", url = "/about" }
|
||||
fr = { name = "/concernant/", url = "/about" }
|
||||
|
||||
[[extra.header_nav]]
|
||||
en = { name = "/journal/", url = "/journal" }
|
||||
fr = { name = "/journal/", url = "/journal" }
|
||||
|
||||
[[extra.header_nav]]
|
||||
en = { name = "/blog/", url = "/blog" }
|
||||
fr = { name = "/blog/", url = "/blog" }
|
||||
header_nav = [
|
||||
{ url = "/", name_en = "/home/", name_fr = "/accueil/" },
|
||||
{ url = "/about", name_en = "/about/", name_fr = "/concernant/" },
|
||||
{ url = "/journal", name_en = "/journal/", name_fr = "/journal/" },
|
||||
{ url = "/blog", name_en = "/blog/", name_fr = "/blog/" }
|
||||
]
|
||||
```
|
||||
|
||||
#### Default Theme
|
||||
|
|
35
config.toml
35
config.toml
|
@ -3,30 +3,16 @@ description = "A minimalist Zola theme that prioritizes clean CSS and avoids hea
|
|||
compile_sass = false
|
||||
minify_html = true
|
||||
generate_feed = true
|
||||
|
||||
default_language = "en"
|
||||
|
||||
taxonomies = [
|
||||
{name = "tags", feed = true},
|
||||
]
|
||||
|
||||
[languages.en]
|
||||
weight = 1
|
||||
title = "anemone"
|
||||
languageName = "English"
|
||||
languageCode = "en"
|
||||
relativeURL = false
|
||||
|
||||
[languages.fr]
|
||||
weight = 2
|
||||
title = "anemone"
|
||||
languageName = "Français"
|
||||
languageCode = "fr"
|
||||
relativeURL = false
|
||||
|
||||
taxonomies = [
|
||||
{name = "tags", feed = true},
|
||||
]
|
||||
|
||||
[markdown]
|
||||
render_emoji = true
|
||||
|
@ -54,18 +40,9 @@ default_theme = "light"
|
|||
list_pages = false
|
||||
twitter_card = true
|
||||
|
||||
[[extra.header_nav]]
|
||||
en = { name = "/home/", url = "/" }
|
||||
fr = { name = "/accueil/", url = "/fr" }
|
||||
|
||||
[[extra.header_nav]]
|
||||
en = { name = "/about/", url = "/about" }
|
||||
fr = { name = "/concernant/", url = "/about" }
|
||||
|
||||
[[extra.header_nav]]
|
||||
en = { name = "/journal/", url = "/journal" }
|
||||
fr = { name = "/journal/", url = "/journal" }
|
||||
|
||||
[[extra.header_nav]]
|
||||
en = { name = "/blog/", url = "/blog" }
|
||||
fr = { name = "/blog/", url = "/blog" }
|
||||
header_nav = [
|
||||
{ url = "/", name_en = "/home/", name_fr = "/accueil/" },
|
||||
{ url = "/about", name_en = "/about/", name_fr = "/concernant/" },
|
||||
{ url = "/journal", name_en = "/journal/", name_fr = "/journal/" },
|
||||
{ url = "/blog", name_en = "/blog/", name_fr = "/blog/" }
|
||||
]
|
|
@ -1,19 +1,18 @@
|
|||
<!doctype html>
|
||||
<html lang="{{ lang }}">
|
||||
<head>
|
||||
<!DOCTYPE html>
|
||||
<html lang="{% if page %}{{ page.lang }}{% else %}{{ config.default_language }}{% endif %}">
|
||||
<head>
|
||||
{% include "head.html" %}
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<header>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
{% include "header.html" %}
|
||||
</header>
|
||||
<main>
|
||||
{% block content %}{% endblock content %}
|
||||
</main>
|
||||
<footer>
|
||||
</header>
|
||||
<main>
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
</main>
|
||||
<footer>
|
||||
{% include "footer.html" %}
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
|
@ -92,4 +92,5 @@
|
|||
{% block css %}
|
||||
<link rel="stylesheet" href="{{ get_url(path='css/style.css', trailing_slash=false) | safe }}"/>
|
||||
{% endblock css %}
|
||||
<script src="{{ get_url(path='js/script.js', trailing_slash=false) | safe }}"></script>
|
||||
<script src="{{ get_url(path='js/script.js', trailing_slash=false) | safe }}" defer></script>
|
||||
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
{% set current_lang = config.default_language %}
|
||||
{% if page %}
|
||||
{% set current_lang = page.lang %}
|
||||
{% elif section %}
|
||||
{% set current_lang = section.lang %}
|
||||
{% endif %}
|
||||
{% if config.extra.header_nav %}
|
||||
<nav class="navBar">
|
||||
{% for nav_item in config.extra.header_nav %}
|
||||
{% set current_nav_item = nav_item[lang] %}
|
||||
{% if current_nav_item and current_nav_item.name %}
|
||||
<a href="{{ get_url(path=current_nav_item.url) }}" {% if current_nav_item.new_tab %}target="_blank"
|
||||
rel="noreferrer noopener" {% endif %}>{{ current_nav_item.name }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<nav class="navBar">
|
||||
{% for nav_item in config.extra.header_nav %}
|
||||
<a href="{{ nav_item.url }}" class="{% if nav_item.url == current_url %}active{% endif %}">
|
||||
{% set language_key = 'name_' ~ current_lang %}
|
||||
{{ nav_item[language_key] }}
|
||||
</a>
|
||||
{% endfor %}
|
||||
|
||||
<div class="themeSwitch">
|
||||
{% if not config.extra.default_theme %}
|
||||
|
|
Loading…
Reference in a new issue