Skip to content

Commit

Permalink
Add polyglot gem (for multi-language)
Browse files Browse the repository at this point in the history
  • Loading branch information
makowildcat committed Jul 11, 2024
1 parent c9aef05 commit 49a750a
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
# do not have a Java counterpart.
gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]

gem 'jekyll-archives'
gem "jekyll-archives"
gem "jekyll-polyglot"
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ GEM
jekyll (>= 3.6, < 5.0)
jekyll-feed (0.17.0)
jekyll (>= 3.7, < 5.0)
jekyll-polyglot (1.8.0)
jekyll (>= 4.0, >= 3.0)
jekyll-sass-converter (3.0.0)
sass-embedded (~> 1.54)
jekyll-seo-tag (2.8.0)
Expand Down Expand Up @@ -111,6 +113,7 @@ DEPENDENCIES
jekyll (~> 4.3.3)
jekyll-archives
jekyll-feed (~> 0.12)
jekyll-polyglot
minima (~> 2.5)
tzinfo (>= 1, < 3)
tzinfo-data
Expand Down
7 changes: 7 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ theme: minima
plugins:
- jekyll-feed
- jekyll-archives
- jekyll-polyglot

jekyll-archives:
enabled:
Expand All @@ -42,6 +43,12 @@ jekyll-archives:
permalinks:
category: '/category/:name/'

# jekyll-polyglot preferences
languages: ["fr", "en"]
default_lang: "fr"
exclude_from_localization: ["javascript", "images", "css", "public"]
parallel_localization: true

# Exclude from processing.
# The following items will not be processed, by default.
# Any item listed under the `exclude:` key here will be automatically added to
Expand Down
7 changes: 7 additions & 0 deletions _data/en/strings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
hello: "Hello"
greetings:
morning: "Good morning"
evening: "Good evening"
lang_name: English
title: Your awesome title
rss_subscribe: 'subscribe <a href="$url">via RSS</a>'
7 changes: 7 additions & 0 deletions _data/fr/strings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
hello: "Bonjour"
greetings:
morning: "Bon matin"
evening: "Bonsoir"
lang_name: Français
title: Votre magnifique titre
rss_subscribe: 'abonnez-vous <a href="$url">par RSS</a>'
7 changes: 5 additions & 2 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<div class="wrapper">

<h2 class="footer-heading">{{ site.title | escape }}</h2>
<h2 class="footer-heading">{{ site.data.strings.title | escape }}</h2>

<div class="footer-col-wrapper">
<div class="footer-col footer-col-1">
Expand All @@ -12,13 +12,16 @@ <h2 class="footer-heading">{{ site.title | escape }}</h2>
{%- if site.author -%}
{{ site.author | escape }}
{%- else -%}
{{ site.title | escape }}
{{ site.data.strings.title | escape }}
{%- endif -%}
</li>
{%- if site.email -%}
<li><a class="u-email" href="mailto:{{ site.email }}">{{ site.email }}</a></li>
{%- endif -%}
</ul>
<div class="lang-switcher">
{%- include lang-switcher.html -%}
</div>
</div>

<div class="footer-col footer-col-2">
Expand Down
4 changes: 3 additions & 1 deletion _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{%- seo -%}
{%- seo title=false -%}
<title>{{ site.data.strings.title }}</title>

<link rel="stylesheet" href="{{ "/assets/main.css" | relative_url }}">
{%- feed_meta -%}
{%- if jekyll.environment == 'production' and site.google_analytics -%}
Expand Down
2 changes: 1 addition & 1 deletion _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="wrapper">
{%- assign default_paths = site.pages | map: "path" -%}
{%- assign page_paths = site.header_pages | default: default_paths -%}
<a class="site-title" rel="author" href="{{ "/" | relative_url }}">{{ site.title | escape }}</a>
<a class="site-title" rel="author" href="{{ "/" | relative_url }}">{{ site.data.strings.title | escape }}</a>

{%- if page_paths -%}
<nav class="site-nav">
Expand Down
12 changes: 12 additions & 0 deletions _includes/lang-switcher.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% for lang in site.languages %}
{% assign lang_name = site.data[lang].strings.lang_name %}
{% if lang == site.active_lang %}
{{ lang_name }}
{% else %}
{% if lang == site.default_lang %}
<a href=" {{ page.url }}">{{ lang_name }}</a>
{% else %}
<a href="/{{ lang }}{{ page.url }}">{{ lang_name }}</a>
{% endif %}
{% endif %}
{% endfor %}
3 changes: 2 additions & 1 deletion _layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ <h3>
{%- endfor -%}
</ul>

<p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | relative_url }}">via RSS</a></p>
{%- assign feed_url = "/feed.xml" | relative_url -%}
<p class="rss-subscribe">{{ site.data.strings.rss_subscribe | replace: "$url", feed_url }}</p>
{%- endif -%}

</div>
8 changes: 8 additions & 0 deletions _posts/en/2024-07-11-test.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
layout: post
title: "Welcome to Test"
date: 2024-07-11 11:46:00 +0200
categories: jekyll
lang: en
---
This is a test.
9 changes: 9 additions & 0 deletions _posts/fr/2024-07-11-test.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: post
title: "Bienvenue au Test"
date: 2024-07-11 11:46:00 +0200
categories: jekyll
lang: fr
---
Ceci est un test.
Coucou !
19 changes: 19 additions & 0 deletions about-en.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
layout: page
title: About
permalink: /about/
lang: en
---

This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](https://jekyllrb.com/)

You can find the source code for Minima at GitHub:
[jekyll][jekyll-organization] /
[minima](https://github.com/jekyll/minima)

You can find the source code for Jekyll at GitHub:
[jekyll][jekyll-organization] /
[jekyll](https://github.com/jekyll/jekyll)


[jekyll-organization]: https://github.com/jekyll
10 changes: 6 additions & 4 deletions about.markdown
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
---
layout: page
title: About
title: À propos
permalink: /about/
lang: fr
---

This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](https://jekyllrb.com/)
C'est le thème de base de Jekyll.
Vous pouvez trouver plus d'information pour personnaliser votre thème, ainsi que de la documentation sur [jekyllrb.com](https://jekyllrb.com/)

You can find the source code for Minima at GitHub:
Vous pouvez trouver le code source code pour Minima sur GitHub:
[jekyll][jekyll-organization] /
[minima](https://github.com/jekyll/minima)

You can find the source code for Jekyll at GitHub:
Vous pouvez trouver le code source pour Jekyll sur GitHub:
[jekyll][jekyll-organization] /
[jekyll](https://github.com/jekyll/jekyll)

Expand Down
9 changes: 9 additions & 0 deletions index-en.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# Feel free to add content and custom Front Matter to this file.
# To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults

layout: home
list_title: Posts List
permalink: /
lang: en
---
3 changes: 3 additions & 0 deletions index.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
# To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults

layout: home
list_title: Liste des Posts
permalink: /
lang: fr
---

0 comments on commit 49a750a

Please sign in to comment.