Cldr.Plug.AcceptLanguage (Cldr v2.26.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.

  • :no_match_log_level determines the logging level for the case when no matching locale is configured to meet the users request. The default is :warn. If set to nil then no logging is performed.

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, options)

View Source

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

Return the locale set by Cldr.Plug.AcceptLanguage