From 544efa97243ff14502b963d94f55388f7f07a5ac Mon Sep 17 00:00:00 2001 From: Speyll Date: Tue, 8 Aug 2023 03:35:07 +0100 Subject: [PATCH] added multilanguage support --- README.md | 48 +++- config.toml | 47 +++- content/_index.fr.md | 47 ++++ content/blog/2020-07-07-overview-post.fr.md | 78 ++++++ content/blog/2020-07-07-overview-post.md | 3 + templates/base.html | 271 +++++++++++--------- 6 files changed, 350 insertions(+), 144 deletions(-) create mode 100644 content/_index.fr.md create mode 100644 content/blog/2020-07-07-overview-post.fr.md diff --git a/README.md b/README.md index 94028a9..c3fcfe3 100644 --- a/README.md +++ b/README.md @@ -47,19 +47,51 @@ Enable listing of pages in the homepage by adding the following code to `config. list_pages = true ``` -#### Header and Footer Nav Links +#### Multilanguage -Customize the header and footer navigation links with the following code in the `extra` section of `config.toml`: +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 + +Customize the header navigation links with the following code in the `extra` section of `config.toml`: ```toml [extra] -header_nav = [ - { name = "/home/", url = "/" }, - { name = "/about/", url = "/about" }, - { name = "/journal/", url = "/journal" }, - { name = "/blog/", url = "/blog" }, -] +[[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" } ``` ### Webrings diff --git a/config.toml b/config.toml index 95384b6..8771c97 100644 --- a/config.toml +++ b/config.toml @@ -1,13 +1,31 @@ base_url = "https://anemone.pages.dev" -title = "anemone" description = "A minimalist Zola theme that prioritizes clean CSS and avoids heavy JavaScript. Enjoy a seamless user experience with lightning-fast load times. Let your content take center stage in a clutter-free, elegant design that enhances readability. Responsive and efficient, anemone brings focus to your ideas." -default_language = "en" compile_sass = false minify_html = true generate_feed = true +default_language = "en" + taxonomies = [ - { name = "tags" }, + {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] @@ -26,15 +44,24 @@ anchors = "on" internal_level = "warn" [extra] -author = "Lyes 'Speyll'" +author = "Speyll" favicon = "favicon.ico" image = "" list_pages = false twitter_card = true -header_nav = [ - { name = "/home/", url = "/" }, - { name = "/about/", url = "/about" }, - { name = "/journal/", url = "/journal" }, - { name = "/blog/", url = "/blog" }, -] \ No newline at end of file +[[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" } diff --git a/content/_index.fr.md b/content/_index.fr.md new file mode 100644 index 0000000..2eba4ca --- /dev/null +++ b/content/_index.fr.md @@ -0,0 +1,47 @@ ++++ ++++ + +## Aperçu + +Le thème anemone est conçu pour offrir une expérience quasi sans JavaScript, efficace et minimaliste pour votre site web. Adoptant la simplicité, le thème met l'accent sur le contenu et la lisibilité, garantissant une expérience utilisateur fluide sans distractions inutiles. + +> *"Bloc de citation inutile"* + +## Articles de Blog + +Explorez nos articles de blog instructifs sur une variété de sujets : + +- 🥣 [Article de présentation](./blog/overview-post) +- 🈚 [Tests de Langue](./blog/language-tests) +- 🔥 [Titre Très Très Très Long et Contenu Très Très Très Court](./blog/very-very-very-long-title-and-very-very-very-short-content) +- 📺 [Exemple d'Article avec Titres et TOC](./blog/post-example-with-headings-and-toc) + +## Étiquettes + +Parcourez nos articles par étiquettes : + +- [exemple](./tags/example) + +## Une Autre Liste + +Découvrez du contenu supplémentaire : + +- Avec des sous-éléments + - Avec des sous-sous-éléments + - [Exemple de Page](./about) +- Cette liste correspond simplement au contenu de `content/_index.md`, les tests sont honteusement volés depuis [no style, please!](https://www.getzola.org/themes/no-style-please/) + +## Présence en Ligne + +Restez connecté avec nous : + +- Email : [jgll6dij6@mozmail.com](mailto:jgll6dij6@mozmail.com) +- Dépôts de Code : [Speyll@GitHub](https://github.com/Speyll) +- @Speyll partout ailleurs. + +## Anneaux Web + +Rejoignez nos anneaux web et explorez davantage : + +- 🈯 {{ webring(prev="#", webring="#", webringName="Anneau Aléatoire", next="#") }} +- 🎶 {{ webring(prev="#", webring="#", webringName="Autre Anneau", next="#") }} \ No newline at end of file diff --git a/content/blog/2020-07-07-overview-post.fr.md b/content/blog/2020-07-07-overview-post.fr.md new file mode 100644 index 0000000..d785d79 --- /dev/null +++ b/content/blog/2020-07-07-overview-post.fr.md @@ -0,0 +1,78 @@ ++++ +title = "Article de Présentation" ++++ + +Lorem ipsum[^1] dolor sit amet, consectetur adipiscing elit. Pellentesque vel lacinia neque. Praesent nulla quam, ullamcorper in sollicitudin ac, molestie sed justo. Cras aliquam, sapien id consectetur accumsan, augue magna faucibus ex, ut ultricies turpis tortor vel ante. In at rutrum tellus. + +# Titre d'exemple 1 +## Titre d'exemple 2 +### Titre d'exemple 3 +#### Titre d'exemple 4 +##### Titre d'exemple 5 +###### Titre d'exemple 6 + +Mauris viverra dictum ultricies. Vestibulum quis ipsum euismod, facilisis metus sed, varius ipsum. Donec scelerisque lacus libero, eu dignissim sem venenatis at. Etiam id nisl ut lorem gravida euismod. + +## Listes + +Non ordonnée : + +- Fusce non velit cursus ligula mattis convallis vel at metus[^2]. +- Sed pharetra tellus massa, non elementum eros vulputate non. +- Suspendisse potenti. + +Ordonnée : + +1. Quisque arcu felis, laoreet vel accumsan sit amet, fermentum at nunc. +2. Sed massa quam, auctor in eros quis, porttitor tincidunt orci. +3. Nulla convallis id sapien ornare viverra. +4. Nam a est eget ligula pellentesque posuere. + +## Bloc de citation + +Voici un bloc de citation : + +> Suspendisse tempus dolor nec risus sodales posuere. Proin dui dui, mollis a consectetur molestie, lobortis vitae tellus. + +## Code + +Maintenant un peu de code : + +```js +const ultimateTruth = 'ce thème est le meilleur !'; +console.log(ultimateTruth); +``` + +Et voici du `code en ligne` ! + +## Tableaux + +Maintenant un tableau : + +| Tables | Sont | Cool | +| ------------- |:-------------:| -----:| +| col 3 est | alignée à droite| $1600 | +| col 2 est | centrée | $12 | +| zèbre | est sympa | $1 | + +## Images + +{{ img(id="https://uploads-ssl.webflow.com/5ff0b3326e5782a256714165/638b6f3a3d8d2e6bad1cb03b_Random22.1.jpg", alt="logo du thème") }} + +image aléatoire d'un chien[^4] + +## Prise en charge multilingue +- 🥣 [Ouvrez cette page traduite en français](./blog/fr/overview-post) + +## Anneaux Web + - 🈯 {{ webring(prev="#", webring="#", webringName="Anneau Aléatoire", next="#") }} + +--- + +[^1]: Ceci est une note de bas de page. Elle devrait être mise en évidence si vous cliquez sur le chiffre en exposant correspondant. + +[^2]: salut toi + +[^3]: ceci est une autre note de bas de page. + +[^4]: ceci est une note de bas de page très très longue pour tester si une note de bas de page très très longue pose problème ou non. J'espère vivement qu'il n'y a pas de problèmes, mais vous savez parfois les problèmes surgissent de nulle part. \ No newline at end of file diff --git a/content/blog/2020-07-07-overview-post.md b/content/blog/2020-07-07-overview-post.md index 6f1db46..fa58fde 100644 --- a/content/blog/2020-07-07-overview-post.md +++ b/content/blog/2020-07-07-overview-post.md @@ -61,6 +61,9 @@ Now a table: random image of a dog[^4] +## Multilanguage support +- 🥣 [Open this page translated to french](https://anemone.pages.dev/blog/fr/overview-post) + ## Webrings - 🈯 {{ webring(prev="#", webring="#", webringName="Random Webring", next="#") }} diff --git a/templates/base.html b/templates/base.html index 0190f32..62b12c7 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,134 +1,153 @@ - - - - - - - - {% if page.title %} - {% set title = page.title %} - {% elif section.title %} - {% set title = section.title %} - {% elif config.title %} - {% set title = config.title %} - {% endif %} - - {% if page.extra.author %} - {% set author = page.extra.author %} - {% elif section.extra.author %} - {% set author = section.extra.author %} - {% elif config.extra.author %} - {% set author = config.extra.author %} - {% endif %} - - {% if page.description %} - {% set description = page.description | truncate(length=150) %} - {% elif section.description %} - {% set description = section.description | truncate(length=150) %} - {% elif config.description %} - {% set description = config.description | truncate(length=150) %} - {% endif %} - - {% if page.extra.image %} - {% set image = get_url(path=page.extra.image, trailing_slash=false) %} - {% elif section.extra.image %} - {% set image = get_url(path=section.extra.image, trailing_slash=false) %} - {% elif config.extra.favicon %} - {% set image = get_url(path=config.extra.favicon, trailing_slash=false) %} - {% endif %} - - {% if page.permalink %} - {% set url = page.permalink %} - {% elif section.permalink %} - {% set url = section.permalink %} - {% elif config.base_url %} - {% set url = config.base_url %} - {% endif %} - - {% if title %}{{ title }}{% endif %} - {% block metatags %} - {% if title %}{% endif %} - {% if author %}{% endif %} - {% if description %}{% endif %} - - - - {% if title %}{% endif %} - {% if title %}{% endif %} - {% if description %}{% endif %} - {% if image %}{% endif %} - - {% set twitter_card = config.extra.twitter_card | default(value=true) %} - {% if twitter_card != false %} - - - {% if title %}{% endif %} - {% if description %}{% endif %} - {% if image %}{% endif %} - {% endif %} - - - {% if image %}{% endif %} - {% endblock metatags %} - {% if config.generate_feed %} - {% block feed %} - - {% endblock feed %} - {% endif %} - {% block css %} - - {% endblock css %} - - - -
-
- - {% if config.extra.header_nav %} - + + + + + + + {% if page.title %} + {% set title = page.title %} + {% elif section.title %} + {% set title = section.title %} + {% elif config.title %} + {% set title = config.title %} {% endif %} + {% if page.extra.author %} + {% set author = page.extra.author %} + {% elif section.extra.author %} + {% set author = section.extra.author %} + {% elif config.extra.author %} + {% set author = config.extra.author %} + {% endif %} + {% if page.description %} + {% set description = page.description | truncate(length=150) %} + {% elif section.description %} + {% set description = section.description | truncate(length=150) %} + {% elif config.description %} + {% set description = config.description | truncate(length=150) %} + {% endif %} + {% if page.extra.image %} + {% set image = get_url(path=page.extra.image, trailing_slash=false) %} + {% elif section.extra.image %} + {% set image = get_url(path=section.extra.image, trailing_slash=false) %} + {% elif config.extra.favicon %} + {% set image = get_url(path=config.extra.favicon, trailing_slash=false) %} + {% endif %} + {% if page.permalink %} + {% set url = page.permalink %} + {% elif section.permalink %} + {% set url = section.permalink %} + {% elif config.base_url %} + {% set url = config.base_url %} + {% endif %} + {% if title %} + {{ title }} + {% endif %} + {% block metatags %} + {% if title %} + + {% endif %} + {% if author %} + + {% endif %} + {% if description %} + + {% endif %} + + + {% if title %} + + {% endif %} + {% if title %} + + {% endif %} + {% if description %} + + {% endif %} + {% if image %} + + {% endif %} + {% set twitter_card = config.extra.twitter_card | default(value=true) %} + {% if twitter_card != false %} + + + {% if title %} + + {% endif %} + {% if description %} + + {% endif %} + {% if image %} + + {% endif %} + {% endif %} + + {% if image %} + + {% endif %} + {% endblock metatags %} + {% if config.generate_feed %} + {% block feed %} + + {% endblock feed %} + {% endif %} + {% block css %} + + {% endblock css %} + + +
+
+ {% if config.extra.header_nav %} +
+
+ + +
+ + {% endif %} -
- {% block content %}{% endblock content %} -
- -
- {% block footer %}{% endblock footer %} -
-
-
-

Licensed under MIT
- Built with Zola using anemone theme & veqev colors.

-
+ +
-
- - footGif - -
+
+ {% block content %}{% endblock content %} +
-
- - - + + +