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:
- Injects
<link rel="alternate" hreflang="…">tags into every HTML page that exists in multiple locales. - Adds an
x-defaultalternate pointing to the default locale. - Generates per-locale sitemaps (
sitemap-en.xml,sitemap-fr.xml, …) withxhtml:linkalternates.
The injection is idempotent — pages that already contain hreflang links are skipped.
Structs§
- I18n
Config - Parsed
[i18n]configuration section. - I18n
Plugin - I18n plugin that injects hreflang links and generates per-locale sitemaps.
Enums§
- UrlPrefix
Strategy - 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).