diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e90669..fd1791b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## Cldr_Currencies v2.14.1 + +This is the changelog for Cldr_Currencies v2.14.1 released on June 8th, 2022. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_currencies/tags) + +### Bug Fixes + +* Fix `Cldr.Currency.currency_from_locale/2` when the first argument is a `t:Cldr.LanguageTag.t/0` + ## Cldr_Currencies v2.14.0 This is the changelog for Cldr_Currencies v2.14.0 released on June 4th, 2022. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_currencies/tags) diff --git a/lib/cldr/currency.ex b/lib/cldr/currency.ex index 84b6c78..4d0fa55 100644 --- a/lib/cldr/currency.ex +++ b/lib/cldr/currency.ex @@ -567,12 +567,19 @@ defmodule Cldr.Currency do :INR """ - def currency_from_locale(locale, backend \\ default_backend()) when is_binary(locale) do - with {:ok, locale} <- Cldr.validate_locale(locale, backend) do + def currency_from_locale(locale, backend \\ nil) + + def currency_from_locale(locale, backend) when is_binary(locale) do + with {locale, backend} <- Cldr.locale_and_backend_from(locale, backend), + {:ok, locale} <- Cldr.validate_locale(locale, backend) do currency_from_locale(locale) end end + def currency_from_locale(%LanguageTag{} = locale, _backend) do + currency_from_locale(locale) + end + @doc """ Returns the effective currency format for a given locale diff --git a/mix.exs b/mix.exs index 5f230c1..d9bfe82 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Cldr.Currencies.MixProject do use Mix.Project - @version "2.14.0" + @version "2.14.1" def project do [ diff --git a/test/cldr_currencies_test.exs b/test/cldr_currencies_test.exs index be0630a..5fe56c5 100644 --- a/test/cldr_currencies_test.exs +++ b/test/cldr_currencies_test.exs @@ -66,4 +66,13 @@ defmodule Cldr.Currency.Test do {:ok, currency} = Cldr.Currency.currency_for_code(:AUD, MyApp.Cldr) assert to_string(currency) == "Australian Dollar" end + + test "Currency from locale" do + {:ok, locale} = Cldr.validate_locale("fr", MyApp.Cldr) + assert _currency = Cldr.Currency.currency_from_locale(locale, MyApp.Cldr) + end + + test "Currency from binary locale" do + assert _currency = Cldr.Currency.currency_from_locale("fr") + end end diff --git a/test/cldr_eteneral_test.exs b/test/cldr_eternal_test.exs similarity index 100% rename from test/cldr_eteneral_test.exs rename to test/cldr_eternal_test.exs