🌐 feat(i18n): overhaul translation system & add languages (#145)
Revamp the existing translation system, simplifying
management and adding several new languages. The new system reads from
TOML files in the `/i18n` directory and improves template structures.
It also enhances customisation options and robustness by providing
fallbacks and modularity.
- Implement a new, streamlined translation macro.
- Load translations from `/i18n` TOML files.
- Remove redundant configuration requirements.
- Refactor templates to align with new i18n system.
- Add support for Hindi, Japanese, Russian, Portuguese, Chinese,
Italian, German, Ukranian, Korean, and French languages.
- Credit Thomas Weitzel (@thomasweitzel) for inspiration.
1 year ago
|
|
|
{% macro toc(page, header, language_strings="") %}
|
|
|
|
|
|
|
|
{%- set toc_levels = page.extra.toc_levels | default(value=3) -%}
|
|
|
|
|
|
|
|
{% if page.extra.toc_ignore_pattern %}
|
|
|
|
{%- set toc_ignore_pattern = page.extra.toc_ignore_pattern -%}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
<div class="toc-container">
|
|
|
|
{% if header %}
|
🌐 feat(i18n): overhaul translation system & add languages (#145)
Revamp the existing translation system, simplifying
management and adding several new languages. The new system reads from
TOML files in the `/i18n` directory and improves template structures.
It also enhances customisation options and robustness by providing
fallbacks and modularity.
- Implement a new, streamlined translation macro.
- Load translations from `/i18n` TOML files.
- Remove redundant configuration requirements.
- Refactor templates to align with new i18n system.
- Add support for Hindi, Japanese, Russian, Portuguese, Chinese,
Italian, German, Ukranian, Korean, and French languages.
- Credit Thomas Weitzel (@thomasweitzel) for inspiration.
1 year ago
|
|
|
<h3>{{ macros_translate::translate(key="table_of_contents", default="Table of Contents", language_strings=language_strings) }}</h3>
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
{% for h1 in page.toc %}
|
|
|
|
{# Only render headers if there's no ignore pattern, or if the header text doesn't match the pattern. #}
|
|
|
|
{% if not toc_ignore_pattern or not (h1.title is matching(toc_ignore_pattern)) %}
|
|
|
|
<li><a href="{{ h1.permalink | safe }}">{{ h1.title }}</a>
|
|
|
|
{% if h1.children and toc_levels > 1 %}
|
|
|
|
<ul>
|
|
|
|
{% for h2 in h1.children %}
|
|
|
|
{% if not toc_ignore_pattern or not (h2.title is matching(toc_ignore_pattern)) %}
|
|
|
|
<li><a href="{{ h2.permalink | safe }}">{{ h2.title }}</a>
|
|
|
|
{% if h2.children and toc_levels > 2 %}
|
|
|
|
<ul>
|
|
|
|
{% for h3 in h2.children %}
|
|
|
|
{% if not toc_ignore_pattern or not (h3.title is matching(toc_ignore_pattern)) %}
|
|
|
|
<li><a href="{{ h3.permalink | safe }}">{{ h3.title }}</a>
|
|
|
|
{% if h3.children and toc_levels > 3 %}
|
|
|
|
<ul>
|
|
|
|
{% for h4 in h3.children %}
|
|
|
|
{% if not toc_ignore_pattern or not (h4.title is matching(toc_ignore_pattern)) %}
|
|
|
|
<li><a href="{{ h4.permalink | safe }}">{{ h4.title }}</a></li>
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% endif %}
|
|
|
|
</li>
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% endif %}
|
|
|
|
</li>
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
{% endif %}
|
|
|
|
</li>
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{% endmacro toc %}
|