# `Localize.Routes.LocalizedHelpers`
[🔗](https://github.com/elixir-localize/localize_web/blob/main/lib/localize/routes/localized_helpers.ex#L1)

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.

# `locale_name`

```elixir
@type locale_name() :: String.t()
```

# `url`

```elixir
@type url() :: String.t()
```

# `define`

For a given set of routes, define a LocalizedHelpers
module that implements localized helpers.

# `hreflang_links`

```elixir
@spec hreflang_links(
  %{required(locale_name()) =&gt; 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_map` is a map of locale to fully-qualified URL, as returned by the
  generated `*_links` helpers. The key `"x-default"` designates the
  fallback variant and is emitted as-is.

* `options` is a keyword list passed to `Localize.HTML.Hreflang.links/2`.

### Returns

* `{:ok, safe}` where `safe` is rendered HTML, or

* `{:error, exception}`.

Anything other than a map, such as `nil`, generates no links.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
