🌐 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.
This commit is contained in:
@@ -1,40 +1,25 @@
|
||||
{% import "macros/translate.html" as macros_translate %}
|
||||
|
||||
{%- import "macros/translate.html" as macros_translate -%}
|
||||
{#- Load the internationalisation data -#}
|
||||
{%- set language_strings = load_data(path="i18n/" ~ lang ~ '.toml', required=false) -%}
|
||||
{%- if not language_strings -%}
|
||||
{%- set language_strings = load_data(path="themes/tabi/i18n/" ~ lang ~ ".toml", required=false) -%}
|
||||
{%- endif -%}
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml-stylesheet href="{{ get_url(path='/feed_style.xsl', trailing_slash=false) | safe }}" type="text/xsl"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:base="http://purl.org/atompub/base/1.0/" xml:lang="{{ lang }}" xml:base="{{ config.base_url }}">
|
||||
{# This section stores the strings/translations for the stylised feed. If the translation is not found, the default English text will be used. #}
|
||||
<str:translations xmlns:str="https://github.com/welpo/tabi">
|
||||
<str:this_is_a_web_feed>
|
||||
{{- macros_translate::translate(key="this_is_a_web_feed", default="This is a web feed") -}}
|
||||
</str:this_is_a_web_feed>
|
||||
<str:also_known_as_an_Atom_feed>
|
||||
{{- macros_translate::translate(key="also_known_as_an_Atom_feed", default="also known as an Atom feed") -}}
|
||||
</str:also_known_as_an_Atom_feed>
|
||||
<str:subscribe>
|
||||
{{- macros_translate::translate(key="subscribe", default="Subscribe") -}}
|
||||
</str:subscribe>
|
||||
<str:by_copying_the_URL_from_the_address_bar_into_your_newsreader>
|
||||
{{- macros_translate::translate(key="by_copying_the_URL_from_the_address_bar_into_your_newsreader", default="by copying the URL from the address bar into your newsreader") -}}
|
||||
</str:by_copying_the_URL_from_the_address_bar_into_your_newsreader>
|
||||
<str:visit>
|
||||
{{- macros_translate::translate(key="visit", default="Visit") -}}
|
||||
</str:visit>
|
||||
<str:to_learn_more_and_get_started>
|
||||
{{- macros_translate::translate(key="to_learn_more_and_get_started", default="to learn more and get started") -}}
|
||||
</str:to_learn_more_and_get_started>
|
||||
<str:it_s_free>
|
||||
{{- macros_translate::translate(key="it_s_free", default="It's free") -}}
|
||||
</str:it_s_free>
|
||||
<str:website>
|
||||
{{- macros_translate::translate(key="website", default="website") -}}
|
||||
</str:website>
|
||||
<str:about_feeds>
|
||||
{{- macros_translate::translate(key="about_feeds", default="This is a web feed, also known as an Atom feed. Subscribe by copying the URL from the address bar into your newsreader", language_strings=language_strings) -}}
|
||||
</str:about_feeds>
|
||||
<str:visit_the_site>
|
||||
{{- macros_translate::translate(key="visit_the_site", default="Visita la web", language_strings=language_strings) -}}
|
||||
</str:visit_the_site>
|
||||
<str:recent_posts>
|
||||
{{- macros_translate::translate(key="recent_posts", default="Recent posts") -}}
|
||||
{{- macros_translate::translate(key="recent_posts", default="Publicaciones recientes", language_strings=language_strings) -}}
|
||||
</str:recent_posts>
|
||||
</str:translations>
|
||||
|
||||
{# Load extra CSS (skin) if set in config.toml #}
|
||||
{#- Load extra CSS (skin) if set in config.toml -#}
|
||||
{%- if config.extra.skin and config.extra.skin != "teal" -%}
|
||||
<link rel="extra-stylesheet" href="{{ get_url(path='skins/' ~ config.extra.skin ~ '.css', cachebust=true) | safe }}" />
|
||||
{%- endif -%}
|
||||
|
Reference in New Issue
Block a user