Skip to content

Commit

Permalink
Use spellout_numbering, not spellout_cardinal
Browse files Browse the repository at this point in the history
  • Loading branch information
kipcole9 committed Sep 11, 2023
1 parent 6e22e52 commit 5e0d054
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 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.32.2

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

### Bug Fixes

* Fixes RBNF rules for fractions. Previous the rule `:spellout_cardinal` was being used to format the fractional part of a number. However this rule is not defined for many locales. This is changed to `:spellout_numbering` which is available in all known locales.

## Cldr Numbers v2.32.1

This is the changelog for Cldr v2.32.0 released on September 9th, 2023. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_numbers/tags)
Expand Down
2 changes: 1 addition & 1 deletion lib/cldr/number/rbnf/processor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ defmodule Cldr.Rbnf.Processor do
|> Integer.to_string()
|> String.split("", trim: true)
|> Enum.map(&String.to_integer/1)
|> Enum.map(&unquote(spellout_module).spellout_cardinal(&1, locale))
|> Enum.map(&unquote(spellout_module).spellout_numbering(&1, locale))
|> Enum.join(" ")
end

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule Cldr.Numbers.Mixfile do

use Mix.Project

@version "2.32.1"
@version "2.32.2"

def project do
[
Expand Down
8 changes: 8 additions & 0 deletions test/number/rbnf_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ defmodule Rbnf.Test do
{:ok, "123rd"}
end

test "RBNF Spellout for spanish" do
assert TestBackend.Cldr.Number.to_string(123.456, format: :spellout_cardinal_masculine, locale: :es) ==
{:ok, "ciento veintitrés punto cuatro cinco seis"}

assert TestBackend.Cldr.Number.to_string(123.456, format: :spellout_cardinal_feminine, locale: :es) ==
{:ok, "ciento veintitrés punto cuatro cinco seis"}
end

Elixir.Cldr.Rbnf.TestSupport.rbnf_tests(fn name, tests, module, function, locale ->
test name do
Enum.each(unquote(Macro.escape(tests)), fn {test_data, test_result} ->
Expand Down

0 comments on commit 5e0d054

Please sign in to comment.