elixir-cldr / cldr

Elixir implementation of CLDR/ICU
Other
440 stars 33 forks source link

Fix typespec for Cldr.with_locale: Allow strings for locale argument #215

Closed nTraum closed 9 months ago

nTraum commented 9 months ago

Cldr.with_locale allows passing strings for the locale, as already verified by one of the tests in test/cldr_test.exs:319

assert Cldr.with_locale("fr", TestBackend.Cldr, fn -> Cldr.get_locale(TestBackend.Cldr) end) == fr_locale
kipcole9 commented 9 months ago

Thanks very much raising the issue and for the PR. I ended up manually updating the code since the right typing for the flexible locale parameter is Cldr.Locale.locale_refernce(). And I needed to apply the same changes to the backend module. I also added a a module to exercise Cldr.with_locale/2,3 so that type bugs get surfaced earlier.

The result is ex_cldr version 2.37.3 with the following changelog entry:

Bug Fixes

Enhancements

nTraum commented 9 months ago

Thanks for the quick response and fixes @kipcole9, appreciate your work!