Ex_Cldr_Numbers v2.11.0 Release Notes

Release Date: 2020-01-18 // almost 2 years ago
  • 🚀 This is the changelog for Cldr v2.11.0 released on January 19th, 2020. For older changelogs please consult the release tag on GitHub

    ✨ Enhancements

    • 👉 Uses the number system defined by the locale if it is specified. The number system is defined as part of the U extension. The order of precedence is:

      • :default if no option is provided to MyApp.Cldr.Number.to_string/2 and no number system is defined in the locale
      • The option :number_system if it is provided to MyApp.Cldr.Number.to_string/2
      • The locale's number_system if it is defined and the option :number_system to MyApp.Cldr.Number.to_string/2 is not provided

    Examples:

     # Locale defines a number system and no option :number_system is provided
     iex> TestBackend.Cldr.Number.to_string(1234, locale: "th-u-nu-thai")
     {:ok, "๑,๒๓๔"}
    
     # Locale defines a number system but an option :number_system is also provded which
     # take precedence
     iex> MyApp.Cldr.Number.to_string 1234, locale: "th-u-nu-latn", number_system: :thai
     {:ok, "๑,๒๓๔"}
    
     # A number system is defined in the locale but it is not supported by the
     # locale
     iex> MyApp.Cldr.Number.to_string 1234, locale: "en-AU-u-nu-thai"
     {:error,
      {Cldr.UnknownNumberSystemError,
       "The number system :thai is unknown for the locale named \"en\". Valid number systems are %{default: :latn, native: :latn}"}}
    
    • 👉 Uses the currency code defined by the locale if it is specified and the number format requested is :currency. The currency code is defined as part of the U extension. The order of precedence is:

      • The option :currency if it is provided to MyApp.Cldr.Number.to_string/2
      • The locale's currency code if it is defined and the option :currency to MyApp.Cldr.Number.to_string/2 is not provided

    Examples:

     # Use the currency code :AUD specified in the locale
     iex> MyApp.Cldr.Number.to_string 1234, locale: "en-AU-u-cu-aud", format: :currency
     {:ok, "A$1,234.00"}
    
     # Use the currency code :USD provided as an option in precedence over the currency code
     # defined by the locale
     iex> MyApp.Cldr.Number.to_string 1234, locale: "en-AU-u-cu-aud", format: :currency, currency: :USD
     {:ok, "$1,234.00"}
    
    • 👉 Uses the currency format defined by the locale if it is specified and the number format requested is :currency or :accounting. The currency format is defined as part of the U extension. The order of precedence is:

      • The locale's currency format if it is defined and the option :format to MyApp.Cldr.Number.to_string/2 is either :currency or :accounting. Therefore the locales currency format takes precendence over the :format argument but only if :format is a currency format.
      • The option :format in every other case

    Examples:

     # Using in the locale currency format - just happens to be the same as the format option
     iex> MyApp.Cldr.Number.to_string -1234, locale: "en-AU-u-cu-aud-cf-standard", format: :currency
     {:ok, "A$-1,234.00"}
    
     # The locale format takes precedence over the format option
     iex> MyApp.Cldr.Number.to_string -1234, locale: "en-AU-u-cu-aud-cf-standard", format: :accounting
     {:ok, "A$-1,234.00"}
    
     iex> MyApp.Cldr.Number.to_string -1234, locale: "en-AU-u-cu-aud-cf-account", format: :accounting
     {:ok, "(A$1,234.00)"}
    
     iex> MyApp.Cldr.Number.to_string -1234, locale: "en-AU-u-cu-aud-cf-account", format: :currency
     {:ok, "(A$1,234.00)"}