<commit_before>---
name: jekyll-multilingual
category: en
---

Setting up a multilingual blog has proven to not be an easy task.I have
experimented back and forth with different kinds of systems, and eventually
landed on [Jekyll] [jekyll] for a couple of reasons.

1. **It's static.**
	I like the idea of functionally generating HTML based on non-html content.

2. **Can be hosted on GitHub.**
	Adminstrating a full linux VPS seemed a bit overkill for a blog, so I'm
happy to find that GitHub can host Jekyll websites. 

3. **It's extendable.**
	Jekyll features a very easy system of extension through it's object model
and templating framework.

Making Jekyll Multilingual
==========================

Jekyll is not multilingual by default, but it is easy to add this
functionality as I found by reading [an article by <NAME>]
[sylvianjekml]. 

One thing to note about how Jekyll builds up the data structures is that after
parsing all of the posts, it makes them avaiable through the `site.posts` array.
This array includes all posts of all languages, so it has to be filtered.


Finding The Next Post
=====================

One feature that I wanted to use in Jekyll that broke after adding multiple
languges was the `page.next` and `page.previous` variables that Jekyll exposes
for post pages.

These variables point to the next and previous post relative to the current one,
but will unfortunately point to posts of another language  most of time.
However, the object returned by these also have the `next` and `previous`
varaibles. Which means you can do `page.next.next.next...` to traverse the
array in relation to the current post.

We can explore forwards or backwards through the post array with a recursive
template. It will keep going until it either finds a post of the correct
language or the value `nil`.
 
{% highlight liquid %}
{% raw %}

{% assign next_post = include.next_post %}

{% if next_post == nil %}
	<!-- No next post -->
{% elsif next_post.lang == page.lang %}
	<a href="{{ next_post.url }}" >Next</a>
{% else %}
	{% include next_button.html next_post=next_post.next %}
{% endif %}

{% endraw %}
{% endhighlight %}

To use it:

{% highlight liquid %}
{% raw %}

{% include next_button.html next_post=page.next %}<commit_msg>Fix spelling in post<commit_after>---
name: jekyll-multilingual
category: en
---

Setting up a multilingual blog has proven to not be an easy task.I have
experimented back and forth with different kinds of systems, and eventually
landed on [Jekyll] [jekyll] for a couple of reasons.

1. **It's static.**
	I like the idea of functionally generating HTML based on non-html content.

2. **Can be hosted on GitHub.**
	Adminstrating a full linux VPS seemed a bit overkill for a blog, so I'm
happy to find that GitHub can host Jekyll websites. 

3. **It's extendable.**
	Jekyll features a very easy system of extension through it's object model
and templating framework.

Making Jekyll Multilingual
==========================

Jekyll is not multilingual by default, but it is easy to add this
functionality as I found by reading [an article by <NAME>]
[sylvianjekml]. 

One thing to note about how Jekyll builds up the data structures is that after
parsing all of the posts, it makes them avaiable through the `site.posts` array.
This array includes all posts of all languages, so it has to be filtered.


Finding The Next Post
=====================

One feature that I wanted to use in Jekyll that broke after adding multiple
languges was the `page.next` and `page.previous` variables that Jekyll exposes
for post pages.

These variables point to the next and previous post relative to the current one,
but will unfortunately point to posts of another language  most of time.
However, the object returned by these also have the `next` and `previous`
variables. Which means you can do `page.next.next.next...` to traverse the
array in relation to the current post.

We can explore forwards or backwards through the post array with a recursive
template. It will keep going until it either finds a post of the correct
language or the value `nil`.
 
{% highlight liquid %}
{% raw %}

{% assign next_post = include.next_post %}

{% if next_post == nil %}
	<!-- No next post -->
{% elsif next_post.lang == page.lang %}
	<a href="{{ next_post.url }}" >Next</a>
{% else %}
	{% include next_button.html next_post=next_post.next %}
{% endif %}

{% endraw %}
{% endhighlight %}

To use it:

{% highlight liquid %}
{% raw %}

{% include next_button.html next_post=page.next %}
{'fraction_non_alphanumeric': 0.09886943028153403, 'fraction_numerical': 0.001330082021724673, 'mean_word_length': 4.1506849315068495, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3309890', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1231, 'n_words': 649}