Skip to content

Cldr Plugs version 1.2.0

Choose a tag to compare

@kipcole9 kipcole9 released this 27 Jul 13:37
· 21 commits to main since this release

Deprecations

  • Deprecate Cldr.Plug.SetLocale in favour of the more consistent Cldr.Plug.PutLocale name.

  • Deprecate the :assigns from key in favour of they key :route. Cldr.Route will, as of version 0.5.0, place the locale in the conn.private.cldr_locale location. from: :route better reflects the intent. The :assigns keyword 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.AcceptLanguage and Cldr.Plug.PutSession dependent on Plug, Plug is a required dependency since this library was split from ex_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 the on_mount callback 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.PutSession now 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.