Cldr v1.6.0 Cldr.Plug.SetLocale View Source
Sets the Cldr and/or Gettext locales derived from the accept-language header, a query parameter, a url parameter, a body parameter or the session.
Options
:apps- list of apps for which to set locale. Valid apps are:cldrand:gettext. The default is:cldr.:from- where in the request to look for the locale. The default is[:session, :accept_language]. The valid options are::accept_languagewill parse theaccept-languageheader and finds the best matched configured locale:pathwill look for a locale by examiningconn.path_params:querywill look for a locale by examiningconn.query_params:bodywill look for a locale by examiningconn.body_params:cookiewill look for a locale in the request cookie(s):sessionwill look for a locale in the session
:default- the default locale to set if no locale is found by other configured methods. It can be a string like “en” or aCldr.LanguageTag.tstruct. The default isCldr.default_locale():gettext- the name of theGettextmodule upon which the locale should be set:session_key- defines the key used to look for the locale in the session. The default is “locale”.
If a locale is found then conn.private[:cldr_locale] is also set.
It can be retrieved with Cldr.Plug.SetLocale.get_cldr_locale/1.
Example
plug Cldr.Plug.SetLocale,
apps: [:cldr, :gettext],
from: [:query, :path, :body, :cookie, :accept_language],
param: "locale",
default: Cldr.default_locale,
gettext: GetTextModule,
session_key: "cldr_locale"
Link to this section Summary
Functions
Return the locale set by Cldr.Plug.SetLocale
Link to this section Functions
Return the locale set by Cldr.Plug.SetLocale