Polyglot 1.10 - Verbesserungen an i18n_headers

Jekyll-Polyglot 1.10 ist jetzt verfügbar. Es gibt große Verbesserungen und Änderungen am i18n_headers Liquid-Plugin für SEO-Verbesserungen sowie kleinere Anpassungen für die Idempotenz beim parallelen Bauen. Community-Beiträge und Vibe Coding haben einen großen Teil dieser Release-Features, Tests und Blogposts beigesteuert.

Verbesserungen an i18n_headers

Das i18n_headers-Plugin hat in dieser Version erweiterte Fähigkeiten:

  • Es fügt für jede Sprachversion einer Seite ein <link rel="canonical" ...> hinzu, sodass das Indexieren für jede Seite eindeutig ist.
  • Es fügt <link rel="alternate" hreflang="x-default" ...> hinzu, um auf die Standardsprachversion einer Seite zu verweisen, wenn keine passende Sprache vom Browser angefordert wird.
  • Es definiert <link rel="alternate" hreflang="..."> korrekt für Seiten und Beiträge in Kollektionen mit benutzerdefinierten Permalinks.
  • Die Standard-URL enthält jetzt site.baseUrl, falls definiert.

Außerdem wurde ein Fehler behoben, der dazu führte, dass die Relativierung absoluter URLs diese Tags unbeabsichtigt verfälschte.

Vibe-Coded-Beiträge

Der Einsatz bestimmter Vibe Coding-Werkzeuge hat geholfen, Fehler und Features für dieses Release zu finden, zu messen und zu verifizieren. Dies ist ein neuer Ansatz in der Softwareentwicklung und ermöglichte fortschrittliche Ruby-Tests gegen Jekyll-Plugin-Code, der auf vielen gebauten Site-Sprachen läuft.

Die mit Vibe Coding geschriebenen Tests halfen, eine hohe Testabdeckung sicherzustellen und komplexe Features mit Vertrauen zu implementieren. Die Automatisierung der Tests sorgte dafür, dass auch schwierige Features korrekt gebaut werden konnten.

Zusätzlich halfen Vibe Coding Tools, diesen Blogpost in viele Sprachen zu übersetzen.

Community-Beiträge

Jekyll-Polyglot wird von Menschen unterstützt. Menschliche Sprachdokumentation wird von Menschen beigetragen, die dieses Plugin in ihrer Muttersprache dokumentiert sehen möchten. Menschen, die Fehlerbehebungen und Dokumentation beitragen, haben dazu beigetragen, dass dieses Plugin bei jeder Veröffentlichung tausende Downloads erreicht. KI-gestützte Programmierung, in meinen oder Ihren Händen, wird die Software, die wir nutzen, und die vielen Sprachen, in denen wir schreiben und sprechen, prägen.

Ruby >= 3.1 erforderlich

Laufende Sicherheitsupdates für die Build-Abhängigkeiten von jekyll-polyglot machten ein großes Upgrade auf Ruby 3.1 erforderlich. Dies kann Build-Systeme betreffen, die ihre Dokumentation mit jekyll-polyglot erstellen. Jetzt ist ein guter Zeitpunkt, auf die neueste Ruby-Hauptversion zu aktualisieren. Melden Sie sich, falls diese Änderungen Komplikationen beim Jekyll-Build verursachen.

Polyglot 1.9.0 - Instructional Improvements

Jekyll-Polyglot 1.9.0 has been released, which has minor dependency updates, and instructional improvements for getting the most from your multi-language website.

Community provided instructional improvements

Thank you to aturret for helping to maintain the existing zh-CN site pages. 谢谢!

george-gca improved the optional derive_lang_from_path configuration to better identify document language from the path inference. Tests were added for his helpful feature improvement PR. This improvement helps infer the language of posts and pages missing lang frontmatter, from any part of the document filepath.

Github user yunseo-kim submitted a instructions to improve sitemap generation . To help with SEO, a website should have only one root sitemap.xml , and not have duplicates for each sub-language site. Be sure to add the sitemap.xml to the exclude_from_localization configuration.

Polyglot 1.8.1 - Community Bug Fixes Release

Jekyll-Polyglot 1.8.1 has been released, which has a few feature improvements and recognizes community found bugs and provided fixes.

Community provided bugfixes

hacketiwack provided a stricter check for setting a doc permalink, preventing downstream problems with empty frontmatter fields.

Github user blackpill submitted a one character bugfix for the i18n headers tag when rendering the default language link alternative href.

Polyglot 1.8.0 - Community-Beiträge-Veröffentlichung

Freuen Sie sich auf Jekyll-Polyglot 1.8.0, das einige Funktionsverbesserungen bietet und Beiträge und Dokumentationen der Community anerkennt!

Eine neue Funktion besteht darin, Seiten sprachspezifische Permalinks zu geben und ihre Verknüpfung mit anderen relativen Seiten beizubehalten. Diese neue Funktion wurde erneut von antoniovazquezblanco verbessert antoniovazquezblanco, ein wahrer Gentleman und Gelehrter.

Sitemap-Generierung & Mehrsprachiges SEO

Diese Version erkennt außerdem die Qualität sitemap.xml und robots.txt solution provided by jerturowetz. Diese Website demonstriert und nutzt jetzt mehr SEO-Leistung, indem sie diese Einstellungen verwendet, um von Suchmaschinen als statische Jekyll-Website gecrawlt werden zu können. Sehen Sie sich die Beispiel-Website-Dateien hier.

jekyll :polyglot :post_write hook

Github-Benutzer obfusk hat vor einigen Jahren PR einen winzigen Beitrag geleistet a:

Mit polyglot :site, :post_write diese Funktion wird einmal pro untergeordnetem Prozess ausgeführt:

Jekyll::Hooks.register :site, :post_write do |site|
  ...
end

Diese Version fügt einen benutzerdefinierten Hook :post_write hinzu, der genau einmal ausgeführt wird, nachdem alle Sprachen verarbeitet wurden (ob parallel_localization verwendet wird):

Jekyll::Hooks.register :polyglot, :post_write do |site|
  # Mach hier etwas Großartiges!
end

Diese Funktion ist hilfreich für komplexe statische Jekyll-Websites, die zusätzlich genutzt werden jekyll hook plugins.

Sie hat außerdem einen Fix für zusätzliche Protokollierung bei Abstürzen von Sprach-Subprozessen. Vielen Dank für diesen Beitrag!

Lokalisierte Variablen und portugiesische Übersetzung

george-gca ist ein talentierter und großartiger Kerl, Er hat einen ganzen Blogbeitrag beigesteuert zum Thema, wie man Rich Text aus Website-Daten am besten lokalisiert. Er hat außerdem die Brasilianische Portugiesisch Website-Übersetzung.

Localized variables

Polyglot allows you to have different pages for different languages in your Jekyll site. For example, one could have a page about.md in English and another about.md in Spanish with completely different layouts. But if you want to have the same layout for both pages, you can use localized variables. This is a way to have different data for different languages in your Jekyll site, but using the same layout for all languages.

As an example I will use a template site created with Polyglot.

Sharing a layout between pages

In that site they have an about page for every language, in their case english in _pages/en-us/about.md and brazilian portuguese in _pages/pt-br/about.md. In both pages we can see that they have the same keys in the frontmatter, but some with different values. Both files point to the same layout, about, and this layout uses the values in the frontmatter to render the page.

For example, the subtitle key in the english page has the value subtitle: <a href='#'>Affiliations</a>. Address. Contacts. Moto. Etc. and in the brazilian portuguese page it has subtitle: <a href='#'>Afiliações</a>. Endereço. Contatos. Lema. Etc.. To use this information in the layout, it is used like this:

{{ page.subtitle }}

The same goes for the content below the frontmatter in both files, which is simply used in the layout like this:

{{ content }}

Polyglot will automatically render the page with the correct values for the current language.

Sharing a layout between pages with localized data

For the subtitle of the page they used key: value pairs in the frontmatter, but sometimes we want to use these same pairs in different parts of the site. For example, if we want to use the same subtitle in the about.md and in another page, we would have to repeat the same pair in the frontmatter of both pages. This is not ideal because if we want to change the subtitle we would have to change it in two places. This is where localized data comes in. You can create a file like _data/:lang/strings.yml, one for each language, and Polyglot will bring those keys under site.data[:lang].strings.

For example, in the template site there are two files, _data/en-us/strings.yml and _data/pt-br/strings.yml. In the first file they have:

latest_posts: latest posts

And in the second file they have:

latest_posts: últimas postagens

This way, they can use the latest_posts key in the layout like this:

{{ site.data[site.active_lang].strings.latest_posts }}

Which will correctly get the value for the latest_posts variable defined in the file _data/:lang/strings.yml for the current language.

Defining which variable to use in the frontmatter

Now if you want to define this variable in the frontmatter of the page, this gets a little bit trickier. One possible solution is to check if the value of the variable has a . in it, and if it does use the value in the file _data/:lang/strings.yml. This is how you would do it:

{% if frontmatter_var contains '.' %}
  {% assign first_part = frontmatter_var | split: '.' | first %}
  {% assign last_part = frontmatter_var | split: '.' | last %}
  {% capture result %}{{ site.data[site.active_lang].strings[first_part][last_part] }}{% endcapture %}
{% endif %}

{{ result }}

This will work, for example, if frontmatter_var = blog.title.

Now, if you need to check if the localization string (in this case blog.title) actually exists in the file _data/:lang/strings.yml before using it, you’ll have to create a plugin to check if the variable exists in the file _data/:lang/strings.yml and if it does, use it, otherwise fallback to any value you want. I will not go into detail on how to do this, but I will show you how to use it. You can see the code for the plugin here.

{% if frontmatter_var contains '.' %}
  {% capture contains_localization %}{% localization_exists {{ frontmatter_var }} %}{% endcapture %}
  {% if contains_localization == 'true' %}
    {% assign first_part = frontmatter_var | split: '.' | first %}
    {% assign last_part = frontmatter_var | split: '.' | last %}
    {% capture result %}{{ site.data[site.active_lang].strings[first_part][last_part] }}{% endcapture %}
  {% else %}
    {% capture result %}fallback value{% endcapture %}
  {% endif %}
{% endif %}

{{ result }}