Cldr Plugs version 1.2.0
Deprecations
-
Deprecate
Cldr.Plug.SetLocalein favour of the more consistentCldr.Plug.PutLocalename. -
Deprecate the
:assignsfromkey in favour of they key:route.Cldr.Routewill, as of version 0.5.0, place the locale in theconn.private.cldr_localelocation.from: :routebetter reflects the intent. The:assignskeyword remains valid with a deprecation warning.
Bug Fixes
-
Fix setting the locale from the result returned from an
{M, f}or{M, f, [a]}. Thanks to @rubas for the PR. -
Don't make modules
Cldr.Plug.AcceptLanguageandCldr.Plug.PutSessiondependent onPlug,Plugis a required dependency since this library was split fromex_cldr. Thanks to @linusdm for the report. Closes #1.
Enhancements
- Adds
Cldr.Session.put_locale/{1, 2}that takes the locale from the session (if there is one) and puts the Cldr locale and/or the Gettext locale into the current process. This is very useful to add to theon_mountcallback in LiveView but it can be applied at any time the session is available. For example:
def on_mount(:default, _params, session, socket) do
{:ok, locale} = Cldr.Session.put_locale(session)
....
end
Cldr.Plug.PutSessionnow has the option to store the full%Cldr.LanguageTag{}into the session, or just the string representation (which the default and the same as previous releases). The tradeoff is space used the session (less than 10 bytes typically for the string, around 500 bytes for the struct) versus the performance hit serializing and parsing the locale when storing it in the session or retrieving it later on.