Skip to main content

Module i18n

Module i18n 

Source
Expand description

Internationalisation: hreflang injection, per-locale sitemaps, lang switcher.

§Internationalisation (i18n) routing primitives

Provides hreflang link injection, per-locale sitemap generation, and a language switcher HTML helper.

§Overview

The I18nPlugin scans the site output directory for locale-prefixed subdirectories (e.g. /en/, /fr/) and:

  1. Injects <link rel="alternate" hreflang="…"> tags into every HTML page that exists in multiple locales.
  2. Adds an x-default alternate pointing to the default locale.
  3. Generates per-locale sitemaps (sitemap-en.xml, sitemap-fr.xml, …) with xhtml:link alternates.

The injection is idempotent — pages that already contain hreflang links are skipped.

Structs§

I18nConfig
Parsed [i18n] configuration section.
I18nPlugin
I18n plugin that injects hreflang links and generates per-locale sitemaps.

Enums§

UrlPrefixStrategy
Strategy for constructing locale-specific URLs.

Functions§

generate_lang_switcher_html
Generates an HTML snippet for a language switcher navigation.
negotiate_locale
Given a list of preferred locales (from Accept-Language) and a list of available locales (directories on disk), returns the best match.
parse_accept_language
Parses an Accept-Language header value into a sorted list of locale preferences (highest quality first).