Generates a module that implements localized route helpers.
At compile time, this module introspects the Phoenix-generated helpers module and creates wrapper functions that dispatch to the correct locale-specific helper based on the current locale. It also generates *_links functions that produce a map of locale-to-URL pairs suitable for hreflang link tags.
Summary
Functions
For a given set of routes, define a LocalizedHelpers module that implements localized helpers.
Generates rel="alternate" hreflang link tags for a map of locale to URL.
Types
Functions
For a given set of routes, define a LocalizedHelpers module that implements localized helpers.
@spec hreflang_links( %{required(locale_name()) => url()} | term(), keyword() ) :: {:ok, Phoenix.HTML.safe()} | {:error, Exception.t()}
Generates rel="alternate" hreflang link tags for a map of locale to URL.
Every locale is validated and rendered in canonical BCP 47 form, and every URL must be fully qualified. A malformed annotation is ignored silently by search engines and agents — the site simply appears not to declare the variant — so an error is returned rather than bad markup emitted.
Arguments
url_mapis a map of locale to fully-qualified URL, as returned by the generated*_linkshelpers. The key"x-default"designates the fallback variant and is emitted as-is.optionsis a keyword list passed toLocalize.HTML.Hreflang.links/2.
Returns
{:ok, safe}wheresafeis rendered HTML, or{:error, exception}.
Anything other than a map, such as nil, generates no links.