View Source I18nHelpers.Plugs.PutLocaleFromPath (I18n Helpers v0.14.0)

Plug to fetch the locale from the first segment of the URL's request path; assigns the locale to the Connection and sets the Gettext locale.

This plug is useful if you have URLs similar to:

https://example.com/fr/bonjour
https://example.com/nl/hallo
https://example.com/es/hola
https://example.com/hello (default locale "en")

Options

  • :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.

Summary

Functions

@spec call(
  Plug.Conn.t(),
  keyword()
) :: Plug.Conn.t()
@spec init(keyword()) :: keyword()