Skip to content

Commit

Permalink
Document currency_symbol: :none option
Browse files Browse the repository at this point in the history
  • Loading branch information
kipcole9 committed Feb 12, 2025
1 parent f6522ae commit a36bb70
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## Cldr Numbers v2.33.6

This is the changelog for Cldr v2.33.6 released on February 13th, 2025. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_numbers/tags)

### Bug Fixes

* Document `currency_symbol: :none`. This option formats a currency amount using a format that does not include a currency symbol.

## Cldr Numbers v2.33.5

This is the changelog for Cldr v2.33.5 released on January 26th, 2025. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_numbers/tags)
Expand Down
7 changes: 4 additions & 3 deletions lib/cldr/number.ex
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ defmodule Cldr.Number do
* `:format` may also be a format defined by CLDR's Rules Based Number
Formats (RBNF). Further information is found in the module `Cldr.Rbnf`.
The most commonly used formats in this category are to spell out the
number in a the locales language. The applicable formats are `:spellout`,
`:spellout_year`, `:ordinal`. A number can also be formatted as roman
number in a locale's language. The applicable formats are `:spellout`,
`:spellout_year` and `:ordinal`. A number can also be formatted as roman
numbers by using the format `:roman` or `:roman_lower`.
* `currency`: is the currency for which the number is formatted. If `currency`
Expand All @@ -202,6 +202,7 @@ defmodule Cldr.Number do
for each currency and can be safely used.
* `:standard` (the default and recommended) uses the CLDR-defined symbol
based upon the currency format for the locale.
* `:none` means format the number without any currency symbol.
* "string" uses `string` as the currency symbol
* `:cash`: a boolean which indicates whether a number being formatted as a
Expand Down Expand Up @@ -229,7 +230,7 @@ defmodule Cldr.Number do
* `:locale`: determines the locale in which the number is formatted. See
`Cldr.known_locale_names/0`. The default is`Cldr.get_locale/0` which is the
locale currently in affect for this `Process` and which is set by
locale currently in affect for the current process and which is set by
`Cldr.put_locale/1`.
* If `:fractional_digits` is set to a positive integer value then the number
Expand Down
12 changes: 9 additions & 3 deletions lib/cldr/number/format/options.ex
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ defmodule Cldr.Number.Format.Options do
:standard,
:iso,
:narrow,
:symbol
:symbol,
:none
]

@type fixed_format :: :standard | :currency | :accounting | :short | :long
@type format :: binary() | fixed_format()
@type currency_symbol :: :standard | :iso
@type currency_symbol :: :standard | :iso | :narrow | :symbol | :none
@type short_format_style ::
:currency_short
| :currency_long
Expand Down Expand Up @@ -242,6 +243,11 @@ defmodule Cldr.Number.Format.Options do
end

@doc false
def resolve_standard_format(%{format: :currency, currency_symbol: :none} = options, backend) do
options = Map.put(options, :format, :currency_no_symbol)
resolve_standard_format(options, backend)
end

def resolve_standard_format(%{format: :currency, currency: nil} = options, backend) do
options = Map.put(options, :format, :currency_no_symbol)
resolve_standard_format(options, backend)
Expand Down Expand Up @@ -609,7 +615,7 @@ defmodule Cldr.Number.Format.Options do
defp validate_option(:currency_symbol, _options, _backend, other) do
{:error,
{ArgumentError,
":currency_symbol must be :standard, :iso, :narrow, :symbol, " <>
":currency_symbol must be :standard, :iso, :narrow, :symbol, :none " <>
"a string or nil. Found #{inspect(other)}"}}
end

Expand Down
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ defmodule Cldr.Numbers.Mixfile do

use Mix.Project

@version "2.33.5"
@version "2.33.6"

def project do
[
app: :ex_cldr_numbers,
version: @version,
elixir: "~> 1.11",
elixir: "~> 1.12",
name: "Cldr Numbers",
description: description(),
source_url: "https://github.com/elixir-cldr/cldr_numbers",
Expand Down
6 changes: 3 additions & 3 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
"digital_token": {:hex, :digital_token, "1.0.0", "454a4444061943f7349a51ef74b7fb1ebd19e6a94f43ef711f7dae88c09347df", [:mix], [{:cldr_utils, "~> 2.17", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "8ed6f5a8c2fa7b07147b9963db506a1b4c7475d9afca6492136535b064c9e9e6"},
"earmark_parser": {:hex, :earmark_parser, "1.4.43", "34b2f401fe473080e39ff2b90feb8ddfeef7639f8ee0bbf71bb41911831d77c5", [:mix], [], "hexpm", "970a3cd19503f5e8e527a190662be2cee5d98eed1ff72ed9b3d1a3d466692de8"},
"erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"},
"ex_cldr": {:hex, :ex_cldr, "2.40.1", "c1fcb0cd9d2a70d28f4540a99f32127e7f1813e0db109d65ab29dea5337ae266", [:mix], [{:cldr_utils, "~> 2.28", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.19", [hex: :gettext, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: true]}], "hexpm", "509810702e8e81991851d9426ffe6b34b48b7b9baa12922e7b3fb8f6368606f3"},
"ex_cldr": {:hex, :ex_cldr, "2.40.2", "1361d06624d7533fb3a2df59c82c7108b18ef55e884f48d503597fce4ce28d97", [:mix], [{:cldr_utils, "~> 2.28", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.19", [hex: :gettext, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: true]}], "hexpm", "cd9039ca9a7c61b99c053a16bd2201ebd7d1c87b49499a4c6d761ec14bca4442"},
"ex_cldr_currencies": {:hex, :ex_cldr_currencies, "2.16.3", "1ec6444b5d0c0aabba5a3bc321d73f1c9c751c6add92e7fb7775ccc071d96bd8", [:mix], [{:ex_cldr, "~> 2.38", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "4d1b5f8449fdf0ece6a2e5c7401ad8fcfde77ee6ea480bddc16e266dfa2b570c"},
"ex_doc": {:hex, :ex_doc, "0.36.1", "4197d034f93e0b89ec79fac56e226107824adcce8d2dd0a26f5ed3a95efc36b1", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "d7d26a7cf965dacadcd48f9fa7b5953d7d0cfa3b44fa7a65514427da44eafd89"},
"ex_doc": {:hex, :ex_doc, "0.37.1", "65ca30d242082b95aa852b3b73c9d9914279fff56db5dc7b3859be5504417980", [:mix], [{:earmark_parser, "~> 1.4.42", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "6774f75477733ea88ce861476db031f9399c110640752ca2b400dbbb50491224"},
"exprintf": {:hex, :exprintf, "0.2.1", "b7e895dfb00520cfb7fc1671303b63b37dc3897c59be7cbf1ae62f766a8a0314", [:mix], [], "hexpm", "20a0e8c880be90e56a77fcc82533c5d60c643915c7ce0cc8aa1e06ed6001da28"},
"exprof": {:hex, :exprof, "0.2.4", "13ddc0575a6d24b52e7c6809d2a46e9ad63a4dd179628698cdbb6c1f6e497c98", [:mix], [{:exprintf, "~> 0.2", [hex: :exprintf, repo: "hexpm", optional: false]}], "hexpm", "0884bcb66afc421c75d749156acbb99034cc7db6d3b116c32e36f32551106957"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"},
"makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"},
"makeup_erlang": {:hex, :makeup_erlang, "1.0.1", "c7f58c120b2b5aa5fd80d540a89fdf866ed42f1f3994e4fe189abebeab610839", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "8a89a1eeccc2d798d6ea15496a6e4870b75e014d1af514b1b71fa33134f57814"},
"makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"},
"nimble_parsec": {:hex, :nimble_parsec, "1.4.2", "8efba0122db06df95bfaa78f791344a89352ba04baedd3849593bfce4d0dc1c6", [:mix], [], "hexpm", "4b21398942dda052b403bbe1da991ccd03a053668d147d53fb8c4e0efe09c973"},
"phoenix_html": {:hex, :phoenix_html, "3.3.4", "42a09fc443bbc1da37e372a5c8e6755d046f22b9b11343bf885067357da21cb3", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "0249d3abec3714aff3415e7ee3d9786cb325be3151e6c4b3021502c585bf53fb"},
"statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"},
Expand Down
1 change: 1 addition & 0 deletions test/support/number_format_test_data.exs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ defmodule Cldr.Test.Number.Format do
{1234, "A$1,234.00", [currency: :AUD, currency_symbol: :standard]},
{1234, "A$1,234.00", [currency: :AUD, currency_symbol: :symbol]},
{1234, "AUD 1,234.00", [currency: :AUD, currency_symbol: :iso]},
{1234, "1,234.00", [currency: :AUD, currency_symbol: :none]},

# Rounding
{1234.21, "1,234.20", [format: "#,##0.05"]},
Expand Down

0 comments on commit a36bb70

Please sign in to comment.