Skip to content

Releases: elixir-cldr/cldr_units

Cldr Units version 3.8.0

28 Oct 00:11
Compare
Choose a tag to compare

Enhancements

  • Updates to use CLDR 40 data. The release notes say:

In CLDR v40, the focus is on Grammatical features (gender and case) for units of measurement in additional locales. In many languages, forming grammatical phrases requires dealing with grammatical gender and case. Without that, it can sound as bad as "on top of 3 hours" instead of "in 3 hours":

  • Phase 1 (CLDR v39) of grammatical features included just 12 locales (da, de, es, fr, hi, it, nl, no, pl, pt, ru, sv).

  • Phase 2 (CLDR v40, this release) has expanded the number of locales by 29 (am, ar, bn, ca, cs, el, fi, gu, he, hr, hu, hy, is, kn, lt, lv, ml, mr, nb, pa, ro, si, sk, sl, sr, ta, te, uk, ur), but for a more restricted number of units.

Deprecations

  • Don't call deprecated Cldr.Config.get_locale/2, use Cldr.Locale.Loader.get_config/2 instead.

  • Don't call deprecated Cldr.Config.known_locale_names/1, call Cldr.Locale.Loader.known_locale_names/1 instead.

Cldr Units version 3.8.0-rc.2

25 Oct 11:16
Compare
Choose a tag to compare
Pre-release

Deprecations

  • Don't call deprecated Cldr.Config.known_locale_names/1, call Cldr.Locale.Loader.known_locale_names/1 instead.

Cldr Units version 3.8.0-rc.1

24 Oct 22:10
Compare
Choose a tag to compare
Pre-release

Bug Fixes

  • Don't call deprecated Cldr.Config.get_locale/2, use Cldr.Locale.Loader.get_config/2 instead.

Cldr Units version 3.8.0-rc.0

03 Oct 14:24
Compare
Choose a tag to compare
Pre-release

Enhancements

  • Updates to use CLDR 40 data. The release notes say:

In CLDR v40, the focus is on Grammatical features (gender and case) for units of measurement in additional locales. In many languages, forming grammatical phrases requires dealing with grammatical gender and case. Without that, it can sound as bad as "on top of 3 hours" instead of "in 3 hours":

  • Phase 1 (CLDR v39) of grammatical features included just 12 locales (da, de, es, fr, hi, it, nl, no, pl, pt, ru, sv).
  • Phase 2 (CLDR v40, this release) has expanded the number of locales by 29 (am, ar, bn, ca, cs, el, fi, gu, he, hr, hu, hy, is, kn, lt, lv, ml, mr, nb, pa, ro, si, sk, sl, sr, ta, te, uk, ur), but for a more restricted number of units.

Cldr Units version 3.7.1

20 Aug 12:31
Compare
Choose a tag to compare

Bug Fixes

  • Fix doc errors. Thanks to @maennchen for the report. Doc errors in other ex_cldr packages are also updated.

Cldr Units version 3.7.0

01 Jul 12:52
Compare
Choose a tag to compare

Enhancements

  • Add support for the Cldr.DisplayName protocol for t:Cldr.Unit structs.

  • Updated to ex_cldr version 2.23.0 which changes the names of some of the fields in the "-u-" extension to match the CLDR canonical name. In particular the field name measurement_system changes to ms. Also the value of ms for the UK System will be :imperial not :uksystem.

Cldr Units version 3.6.0

11 Jun 08:21
Compare
Choose a tag to compare

Enhancements

  • Add Cldr.Unit.parse/2 to parse unit strings of the form 1kg into a t:Cldr.Unit struct.

Cldr Units version 3.5.2

12 Apr 10:14
Compare
Choose a tag to compare

Bug Fixes

  • Fix getting a unit pattern when the unit value is zero, one or two and there is no pattern for the default unit plural category. Thanks to @syfgkjasdkn for the report. Closes #21.

Cldr Units version 3.5.1

11 Apr 06:55
Compare
Choose a tag to compare

Bug Fixes

  • Use :other plural category to format units which have a value of 0, 1 or 2 when the natural unit pattern has no substitutions. This corrects the situation in locales such as he and ar where the unit pattern for plural category :one has no substitutions. Previously this would means the formatted string for a unit with a vaue of 1 and -1 would both output the same string. Thanks to @jarrodmoldrich for the report and to @voltone for his family's help with hebrew grammar.

Cldr Units version 3.5.0

08 Apr 03:48
Compare
Choose a tag to compare

Overview

In this release the Cldr.Unit.to_string/{1, 2, 3} function has been rewritten and the concrete impementation is now in Cldr.Unit.Format. The primary reasons for rewriting are:

  1. Improves performance by 20% over the old implementation.
  2. Supports grammatical case and grammatical gender. These allow for better sentence formation in a localised fashion. Only are few locales have the required data for now (for example, fr and de) however more locales will have data in upcoming CLDR releases.

Note that full testing of grammatical case and grammatical gender variations is not yet complete.

Soft Deprecation

  • The function Cldr.Unit.to_iolist/{1, 2, 3} is soft deprecated. It is still available and no deprecation warning is emitted. It will however be removed from the public API in a future release. This function is primarily used to support implementation of Cldr.Unit.to_string/3

  • As of this release, argument checking in Cldr.Unit.to_iolist/3 is less rigorous in order to avoid the relatively expensive argument normalization process happening twice (once in Cldr.Unit.to_string/3 and then again in Cldr.Unit.to_iolist/3).

Bug Fixes

  • The new string formatter correctly assembles units with an SI prefix (ie millimeter) in languages such as German where the noun is capitalized.

  • Fixes calculating the base unit when the unit is a complex compound unit.

  • Remove double parsing when calling Cldr.Unit.new/2 and the unit is not in Cldr.Unit.known_units/0

  • Ensure Cldr.Unit.unit_category/1 returns an error tuple if the category is unknown

Enhancements

  • Updated to require ex_cldr version 2.20 which includes CLDR 39 data.

  • Add Cldr.Unit.validate_grammatical_gender/2

  • Add Cldr.Unit.known_grammatical_cases/0

  • Add Cldr.Unit.known_grammatical_genders/0

  • Add Cldr.Unit.known_measurement_system_names/0

  • Add Cldr.Unit.invert/1 to invert a "per" unit. This allows for increased compatibility for conversions. For example, "liters per 100 kilometers" is a measure of consumption, as is "miles per gallon". However these two units are not convertible without inverting one of them first since one is "volume per length" and the other is "length per volume".

  • Add Cldr.Unit.conversion_for/2 to return a conversion list used when converting one unit to another.

  • Add Cldr.Unit.grammatical_gender/2 to return the grammatical gender for a given unit and locale

  • Add Cldr.Unit.conversion_for/2 to return a conversion list used when converting one unit to another.

  • Add support for grammatical cases for Cldr.Unit.to_string/2 and Cldr.Unit.to_iolist/2. Not all locales support more than the nominative case. The nominative case is the default. Any configured "Additional Units" in a backend module will need to be modified to put the localisations a map with the key :nominative. See the readme for more information on migrating additional units. On example is:

defmodule MyApp.Cldr do
  use Cldr.Unit.Additional

  use Cldr,
    locales: ["en", "fr", "de", "bs", "af", "af-NA", "se-SE"],
    default_locale: "en",
    providers: [Cldr.Number, Cldr.Unit, Cldr.List]

  unit_localization(:person, "en", :long,
    nominative: %{
      one: "{0} person",
      other: "{0} people"
    },
    display_name: "people"
  )
end
  • Support conversions where one of the base units is the inverted conversion of the other. This allows conversion between, for example, mile per gallon and liter per 100 kilometer. These are both compound units of length and volume but are inverse representations from each other.