I18n Helpers v0.5.1 I18nHelpers.Plugs.PutLocaleFromDomain View Source

Plug to fetch the locale from the URL's subdomain; assigns the locale to the Connection and sets the Gettext locale.

This plug is useful if you have URLs similar to:

https://mon-super-site.example/bonjour
https://mijn-geweldige-website.example/hallo
https://mi-gran-sitio.example/hola
https://my-awesome-website.example/hello

Options

  • :domains_locales_map - map where each key represents a domain and each value contains the locale to be used for that domain
  • :default_locale - locale to be used if no locale was found in the URL
  • :allowed_locales - a list of allowed locales. If no locale was found, use the :default locale if specified, otherwise raise an error.

:domains_locales_map is a mandatory option. Below is an example of a map it can hold:

%{
  "mon-super-site.example" => "fr",
  "mijn-geweldige-website.example" => "nl",
  "mi-gran-sitio.example" => "es",
  "my-awesome-website.example" => "en"
}

Link to this section Summary

Link to this section Functions