Cldr.Plug.AcceptLanguage (Cldr v2.21.0) View Source

Parses the accept-language header if one is available and sets conn.private[:cldr_locale] accordingly. The locale can be later retrieved by Cldr.Plug.AcceptLanguage.get_cldr_locale/1

Options

  • :cldr_backend is any backend module. The default is Cldr.default_backend/0. If no :cldr_backend option is provided and no default backend is configured then an exception will be raised.

Example

# Using a specific backend to validate
# and match locales
plug Cldr.Plug.AcceptLanguage,
  cldr_backend: MyApp.Cldr

# Using the default backend to validate
# and match locales
plug Cldr.Plug.AcceptLanguage

Link to this section Summary

Functions

Returns the locale which is the best match for the provided accept-language header

Link to this section Functions

Link to this function

best_match(accept_language, backend)

View Source

Returns the locale which is the best match for the provided accept-language header

Return the locale set by Cldr.Plug.AcceptLanguage