View Source Cldr.Route.LocalizedHelpers (Cldr Routes v0.6.0)
Generates a module that implements localised helpers.
It introspects the generated helpers module and creates a wrapper function that translates (at compile time) the path segments.
Link to this section Summary
Functions
For a given set of routes, define a LocalizedHelpers module that implements localized helpers.
Generates HTML link
tags for a given map of locale => URLs
Link to this section Types
Link to this section Functions
For a given set of routes, define a LocalizedHelpers module that implements localized helpers.
@spec hreflang_links(%{required(locale_name()) => url()}) :: Phoenix.HTML.safe()
Generates HTML link
tags for a given map of locale => URLs
This function generates <link ... />
tags that should be placed in the
<head>
section of an HTML document to indicate the different language
versions of a given page.
The MyApp.Router.LocalizedHelpers.<helper>_link
functions can
generate the required mapping from locale to URL for a given helper.
These _link
helpers take the same arguments as the _path
and
_url
helpers.
If the helper refers to a route that is not localized then an empty string will be returned since there are no alternative localizations of this route.
See https://developers.google.com/search/docs/advanced/crawling/localized-versions#http
example
Example
===> MyApp.Helpers.LocalizedHelpers.user_links(conn, :show, 1)
...> |> Cldr.Route.LocalizedHelpers.hreflang_links()