From 6df4256af76bb338c35a81b46eb6ea8839624e2d Mon Sep 17 00:00:00 2001 From: Kip Cole Date: Wed, 2 Mar 2022 17:08:17 +0800 Subject: [PATCH] Conform to atom keys in ex_cldr 2.26 --- CHANGELOG.md | 10 +- config/config.exs | 2 +- config/dev.exs | 2 +- config/release.exs | 1 + config/test.exs | 2 +- lib/cldr_html.ex | 1 - lib/cldr_html_currencies.ex | 2 +- lib/cldr_html_locale.ex | 30 +++--- lib/cldr_html_territories.ex | 14 +-- lib/cldr_html_units.ex | 5 +- mix.exs | 21 ++--- mix.lock | 42 ++++----- mix/my_app_cldr.ex | 4 +- test/cldr_html_currency_test.exs | 69 +++++++------- test/cldr_html_locale_test.exs | 72 +++++++------- test/cldr_html_territory_test.exs | 152 ++++++++++++++++-------------- test/cldr_html_unit_test.exs | 90 +++++++++--------- 17 files changed, 269 insertions(+), 250 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fda1449..ba271cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,20 @@ # Changelog +## Cldr_HTML v1.2.0 + +This is the changelog for Cldr HTML v1.2.0 released on March 2nd, 2022. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_html/tags) + +### Enhancements + +* Updates to [ex_cldr version 2.26.0](https://hex.pm/packages/ex_cldr/2.26.0) which uses atoms for locale names and rbnf locale names. This is consistent with out elements of `t:Cldr.LanguageTag` where atoms are used where the cardinality of the data is fixed and relatively small and strings where the data is free format. + ## Cldr_HTML v1.1.0 This is the changelog for Cldr HTML v1.1.0 released on September 25th, 2021. For older changelogs please consult the release tag on [GitHub](https://github.com/elixir-cldr/cldr_html/tags) ### Bug Fixes -* Support `phoenix_html` version 3.0 in additional to earlier releases. +* Support `phoenix_html` version 3.0 in addition to earlier releases. ## Cldr_HTML v1.0.1 diff --git a/config/config.exs b/config/config.exs index 8233fe9..871a3d1 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,3 +1,3 @@ -use Mix.Config +import Config import_config "#{Mix.env()}.exs" diff --git a/config/dev.exs b/config/dev.exs index da5848f..b2efec8 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -1,4 +1,4 @@ -use Mix.Config +import Config config :ex_cldr, default_locale: "en-001", diff --git a/config/release.exs b/config/release.exs index e69de29..8b13789 100644 --- a/config/release.exs +++ b/config/release.exs @@ -0,0 +1 @@ + diff --git a/config/test.exs b/config/test.exs index da5848f..b2efec8 100644 --- a/config/test.exs +++ b/config/test.exs @@ -1,4 +1,4 @@ -use Mix.Config +import Config config :ex_cldr, default_locale: "en-001", diff --git a/lib/cldr_html.ex b/lib/cldr_html.ex index 2b9ac90..31f4958 100644 --- a/lib/cldr_html.ex +++ b/lib/cldr_html.ex @@ -20,5 +20,4 @@ defmodule Cldr.HTML do if Cldr.Code.ensure_compiled?(Cldr.LocaleDisplay) do defdelegate locale_select(form, field, options), to: Cldr.HTML.Locale, as: :select end - end diff --git a/lib/cldr_html_currencies.ex b/lib/cldr_html_currencies.ex index 06d4f8b..6d9c5f1 100644 --- a/lib/cldr_html_currencies.ex +++ b/lib/cldr_html_currencies.ex @@ -97,7 +97,7 @@ if Cldr.Code.ensure_compiled?(Cldr.Currency) do select_options = options |> Map.drop(@omit_from_select_options) - |> Map.to_list + |> Map.to_list() options = options diff --git a/lib/cldr_html_locale.ex b/lib/cldr_html_locale.ex index 0bb803a..09fc240 100644 --- a/lib/cldr_html_locale.ex +++ b/lib/cldr_html_locale.ex @@ -18,10 +18,10 @@ if Cldr.Code.ensure_compiled?(Cldr.LocaleDisplay) do ] @type locale :: %{ - locale: String.t(), - display_name: String.t(), - language_tag: Cldr.LanguageTag.t() - } + locale: String.t(), + display_name: String.t(), + language_tag: Cldr.LanguageTag.t() + } @type mapper :: (locale() -> String.t()) @@ -124,15 +124,21 @@ if Cldr.Code.ensure_compiled?(Cldr.LocaleDisplay) do # Selected currency @omit_from_select_options [ - :locales, :locale, :mapper, :collator, :backend, - :add_likely_subtags, :prefer, :compound_locale + :locales, + :locale, + :mapper, + :collator, + :backend, + :add_likely_subtags, + :prefer, + :compound_locale ] defp select(form, field, options, _selected) do select_options = options |> Map.drop(@omit_from_select_options) - |> Map.to_list + |> Map.to_list() options = options @@ -187,8 +193,7 @@ if Cldr.Code.ensure_compiled?(Cldr.LocaleDisplay) do |> Map.take([:add_likely_subtags]) |> Map.to_list() - backend = - options[:backend] + backend = options[:backend] with {:ok, locale} <- Locale.canonical_language_tag(selected, backend, list_options) do {:ok, Map.put(options, :selected, locale)} @@ -207,11 +212,10 @@ if Cldr.Code.ensure_compiled?(Cldr.LocaleDisplay) do |> Map.take([:add_likely_subtags]) |> Map.to_list() - backend = - options[:backend] + backend = options[:backend] Enum.reduce_while(locales, [], fn locale, acc -> - case Locale.canonical_language_tag(locale, backend, list_options) do + case Locale.canonical_language_tag(to_string(locale), backend, list_options) do {:ok, locale} -> {:cont, [locale | acc]} {:error, reason} -> {:halt, {:error, reason}} end @@ -242,6 +246,7 @@ if Cldr.Code.ensure_compiled?(Cldr.LocaleDisplay) do defp validate_locale(locale, options) do {locale, backend} = Cldr.locale_and_backend_from(locale, options.backend) + with {:ok, locale} <- Cldr.validate_locale(locale, backend) do options |> Map.put(:locale, locale) @@ -301,4 +306,3 @@ if Cldr.Code.ensure_compiled?(Cldr.LocaleDisplay) do end end end - diff --git a/lib/cldr_html_territories.ex b/lib/cldr_html_territories.ex index db2b1f0..24f7199 100644 --- a/lib/cldr_html_territories.ex +++ b/lib/cldr_html_territories.ex @@ -24,10 +24,10 @@ if Cldr.Code.ensure_compiled?(Cldr.Territory) do """ @type territory :: %{ - territory: atom(), - name: String.t(), - flag: String.t() - } + territory: atom(), + name: String.t(), + flag: String.t() + } @doc """ Generate an HTML select tag for a territory list @@ -119,7 +119,7 @@ if Cldr.Code.ensure_compiled?(Cldr.Territory) do select_options = options |> Map.drop(@omit_from_select_options) - |> Map.to_list + |> Map.to_list() options = options @@ -201,7 +201,9 @@ if Cldr.Code.ensure_compiled?(Cldr.Territory) do options end - defp maybe_include_selected_territory(%{territories: territories, selected: selected} = options) do + defp maybe_include_selected_territory( + %{territories: territories, selected: selected} = options + ) do if Enum.any?(territories, &(&1 == selected)) do options else diff --git a/lib/cldr_html_units.ex b/lib/cldr_html_units.ex index 496218f..6bacbb1 100644 --- a/lib/cldr_html_units.ex +++ b/lib/cldr_html_units.ex @@ -98,7 +98,7 @@ if Cldr.Code.ensure_compiled?(Cldr.Unit) do select_options = options |> Map.drop(@omit_from_select_options) - |> Map.to_list + |> Map.to_list() options = options @@ -124,7 +124,7 @@ if Cldr.Code.ensure_compiled?(Cldr.Unit) do backend: nil, locale: Cldr.get_locale(), collator: &default_collator/1, - mapper: &(&1), + mapper: & &1, style: :long, selected: nil ) @@ -225,6 +225,5 @@ if Cldr.Code.ensure_compiled?(Cldr.Unit) do defp default_unit_list() do Cldr.Unit.known_units() end - end end diff --git a/mix.exs b/mix.exs index e5487ca..4303ec5 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Cldr.Html.MixProject do use Mix.Project - @version "1.1.0" + @version "1.2.0" def project do [ @@ -21,8 +21,9 @@ defmodule Cldr.Html.MixProject do package: package(), dialyzer: [ ignore_warnings: ".dialyzer_ignore_warnings", - plt_add_apps: ~w(ex_money ex_cldr_units ex_cldr_territories ex_cldr_locale_display ratio ex_cldr_numbers ex_cldr_currencies)a - ], + plt_add_apps: + ~w(ex_money ex_cldr_units ex_cldr_territories ex_cldr_locale_display ratio ex_cldr_numbers ex_cldr_currencies)a + ] ] end @@ -33,7 +34,6 @@ defmodule Cldr.Html.MixProject do """ end - # Run "mix help compile.app" to learn about applications. def application do [ extra_applications: [:logger] @@ -74,16 +74,15 @@ defmodule Cldr.Html.MixProject do } end - # Run "mix help deps" to learn about dependencies. defp deps do [ - {:ex_cldr, "~> 2.23"}, - {:ex_cldr_currencies, "~> 2.11", optional: true}, - {:ex_cldr_units, "~> 3.7", optional: true}, - {:ex_cldr_locale_display, "~> 1.0", optional: true}, - {:ex_cldr_territories, "~> 2.2", optional: true}, + {:ex_cldr, "~> 2.26"}, + {:ex_cldr_currencies, "~> 2.13", optional: true}, + {:ex_cldr_units, "~> 3.12", optional: true}, + {:ex_cldr_locale_display, "~> 1.3", optional: true}, {:ex_cldr_collation, "~> 0.5", optional: true}, - {:ex_money, "~> 5.0", optional: true}, + {:ex_money, "~> 5.9", optional: true}, + {:phoenix_html, "~> 1.2 or ~> 2.0 or ~> 3.0"}, {:jason, "~> 1.0", optional: true}, {:poison, "~> 2.1 or ~> 3.0 or ~> 4.0", optional: true}, diff --git a/mix.lock b/mix.lock index c79b773..1dbf25b 100644 --- a/mix.lock +++ b/mix.lock @@ -1,34 +1,28 @@ %{ - "abnf2": {:hex, :abnf2, "0.1.4", "9a424cfe94556c0e3e58b02326c39383b170dde4777913fcbdbdfcd2f1b0a97f", [:mix], [], "hexpm"}, - "cldr_utils": {:hex, :cldr_utils, "2.16.0", "5abd1835151e264f6f9a285ab8c7419954a45eec5ca5a356dea592faa23e80b9", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "3ef5dc0fdfe566a5a4b8bda726cf760ebada69c0600affc4cb02b5e8ae7f7b47"}, + "cldr_utils": {:hex, :cldr_utils, "2.17.1", "d5532ccfbe4b39cb652ba4566571324278344a6a2fb4500dac213ce8e123732f", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "052e0c2cf5ee801018580d69939b25528730d73ea05a05cb2c0e0a8204856d76"}, "coerce": {:hex, :coerce, "1.0.1", "211c27386315dc2894ac11bc1f413a0e38505d808153367bd5c6e75a4003d096", [:mix], [], "hexpm", "b44a691700f7a1a15b4b7e2ff1fa30bebd669929ac8aa43cffe9e2f8bf051cf1"}, "decimal": {:hex, :decimal, "2.0.0", "a78296e617b0f5dd4c6caf57c714431347912ffb1d0842e998e9792b5642d697", [:mix], [], "hexpm", "34666e9c55dea81013e77d9d87370fe6cb6291d1ef32f46a1600230b1d44f577"}, "dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"}, - "earmark": {:hex, :earmark, "1.3.6", "ce1d0675e10a5bb46b007549362bd3f5f08908843957687d8484fe7f37466b19", [:mix], [], "hexpm", "1476378df80982302d5a7857b6a11dd0230865057dec6d16544afecc6bc6b4c2"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.15", "b29e8e729f4aa4a00436580dcc2c9c5c51890613457c193cc8525c388ccb2f06", [:mix], [], "hexpm", "044523d6438ea19c1b8ec877ec221b008661d3c27e3b848f4c879f500421ca5c"}, - "elixir_make": {:hex, :elixir_make, "0.6.2", "7dffacd77dec4c37b39af867cedaabb0b59f6a871f89722c25b28fcd4bd70530", [:mix], [], "hexpm", "03e49eadda22526a7e5279d53321d1cced6552f344ba4e03e619063de75348d9"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.20", "89970db71b11b6b89759ce16807e857df154f8df3e807b2920a8c39834a9e5cf", [:mix], [], "hexpm", "1eb0d2dabeeeff200e0d17dc3048a6045aab271f73ebb82e416464832eb57bdd"}, + "elixir_make": {:hex, :elixir_make, "0.6.3", "bc07d53221216838d79e03a8019d0839786703129599e9619f4ab74c8c096eac", [:mix], [], "hexpm", "f5cbd651c5678bcaabdbb7857658ee106b12509cd976c2c2fca99688e1daf716"}, "erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"}, - "ex_cldr": {:hex, :ex_cldr, "2.23.2", "76c51b722cefdcd1a13eb5e7c7f4da5b9acfd64ff054424a977ff6e2d6a78981", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:cldr_utils, "~> 2.15", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:gettext, "~> 0.13", [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]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "d9ce03c8d3fdc7ab751bdb2be742b6972f94adc856d51dfe5bb06a51ac96b8f4"}, - "ex_cldr_collation": {:hex, :ex_cldr_collation, "0.6.0", "c748c34a411b8a0cef5754e29b95223795c740170c632b6a9dd706dcfa5b71e6", [:mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "4bba917037df921de143e9d53adff549a06ab7fcd50ef902c6e7842d26d6fa2d"}, - "ex_cldr_currencies": {:hex, :ex_cldr_currencies, "2.11.1", "a6e56209d6f98082cd197aa424333e7a0e38e79253fce9589117719728de4fef", [:mix], [{:ex_cldr, "~> 2.23", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_doc, "~> 0.18", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "99e8eb3f48a30127bb11ab70f484c124c9fe5b11bce710c94c53939032b0c58c"}, - "ex_cldr_lists": {:hex, :ex_cldr_lists, "2.8.0", "373d8574d28590fdbc475436cc1590d37200867b4116f69a51e6e57cb0e62ee6", [:mix], [{:ex_cldr_numbers, "~> 2.17", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:ex_doc, "~> 0.18", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "455406d488452d6eb0b044e23a918e015418787ffc87791d81e7320742269483"}, - "ex_cldr_locale_display": {:hex, :ex_cldr_locale_display, "1.1.2", "36f1faf123a800a010ddc1a5b3d9b870b73bcadb744e0e14ff8d9e2efc357941", [:mix], [{:ex_cldr, "~> 2.23", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, "~> 2.11", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:ex_cldr_territories, "~> 2.2", [hex: :ex_cldr_territories, repo: "hexpm", optional: false]}, {:ex_doc, "~> 0.18", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "c3191f392104af7dfad2611c094f858738cebc95963b15e2f65d204090f982a3"}, - "ex_cldr_numbers": {:hex, :ex_cldr_numbers, "2.22.1", "c710abb30a89875a5e2aff5f8a5e073ffad8689c6e84034729f10c51d39c4dcf", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ex_cldr, "~> 2.23", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, "~> 2.11", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:ex_doc, "~> 0.18", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "2015161a54f583eede00f18cdf43ec2b27aecf53e22486f6158d787da1f02bb9"}, - "ex_cldr_territories": {:hex, :ex_cldr_territories, "2.2.2", "f7f3cdc0ed1b9948bd05565275f830738e2e2d9eb356b15ade4d6e3b643dbfbf", [:mix], [{:ex_cldr, "~> 2.20", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "931144e831eec3a337dec56b4009dbe6e5e16ff72f6de5b698c40431277b5442"}, - "ex_cldr_units": {:hex, :ex_cldr_units, "3.7.1", "89241de864e4673fe352d15d5727d89c63c10ce9c271b827c07452719f5e2a16", [:mix], [{:cldr_utils, "~> 2.16", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:ex_cldr_lists, "~> 2.8", [hex: :ex_cldr_lists, repo: "hexpm", optional: false]}, {:ex_cldr_numbers, "~> 2.19", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:ex_doc, "~> 0.18", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:ratio, "~> 2.4", [hex: :ratio, repo: "hexpm", optional: false]}], "hexpm", "b9595bea124b6355632784bc8fb4a924c6456f1934a9a80359622e52b9bcdeb6"}, - "ex_doc": {:hex, :ex_doc, "0.25.3", "3edf6a0d70a39d2eafde030b8895501b1c93692effcbd21347296c18e47618ce", [:mix], [{:earmark_parser, "~> 1.4.0", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "9ebebc2169ec732a38e9e779fd0418c9189b3ca93f4a676c961be6c1527913f5"}, - "ex_money": {:hex, :ex_money, "5.6.0", "f95b3ff03b5ae015d717f86d49bbf08d82b3e984b958799bb1061d79374110d4", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ex_cldr_numbers, "~> 2.16", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.0 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "fe8ac94f67bd461476011cb2bb90e8517769a734e5c23da649eb77c120081308"}, - "jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"}, - "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, - "makeup_elixir": {:hex, :makeup_elixir, "0.15.1", "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"}, + "ex_cldr": {:hex, :ex_cldr, "2.26.3", "92f30e61f3114936141996a69622274d068a0abe6da405c63169eb744f1a5628", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:cldr_utils, "~> 2.17", [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]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "14470e0c8026201e6641a96c45f6a76295c5f41c316bcbdc3a0a34ac11eea903"}, + "ex_cldr_collation": {:hex, :ex_cldr_collation, "0.7.0", "45908541451b6ae3d1a5928f2c2bf83b36de0249353efb64a4b0dae4cd175ed6", [:mix], [{:elixir_make, "~> 0.4", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "a59f77b058632ef2d1119b718c523afc701c5e0d1d22a7dbee25c8c8afca4988"}, + "ex_cldr_currencies": {:hex, :ex_cldr_currencies, "2.13.0", "13188b99e527d724ed3dc2af37e54f0dac42dec42b620a34c4ed4d4902fad6dd", [:mix], [{:ex_cldr, "~> 2.24", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "64731e49ac3530aa88872b52c319eb5231bfb1a3ebb0956044c34abc0ed4f520"}, + "ex_cldr_lists": {:hex, :ex_cldr_lists, "2.10.0", "4d4c9877da2d0417fd832907d69974e8328969f75fafc79b05ccf85f549f6281", [:mix], [{:ex_cldr_numbers, "~> 2.25", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:ex_doc, "~> 0.18", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "adc040cde7b97f7fd7c0b35dd69ddb6fcf607303ae6355bb1851deae1f8b0652"}, + "ex_cldr_locale_display": {:hex, :ex_cldr_locale_display, "1.3.0", "1ab8053b054b0d3f1b0cadc2a576ecd87344d958561b32a7643f60d4f332c4e0", [:mix], [{:ex_cldr, "~> 2.26", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, "~> 2.12", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:ex_cldr_territories, "~> 2.4", [hex: :ex_cldr_territories, repo: "hexpm", optional: false]}, {:ex_doc, "~> 0.18", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "fd1245fe0d6f1cf46fbfcabcb8bc2dd90f3eac4b6d0c0d77927b73c21b4b72f6"}, + "ex_cldr_numbers": {:hex, :ex_cldr_numbers, "2.25.2", "9bd1f21bb7a300e1e0fd080b99f0c912d2adf90292e7d7c0335a6da84758c8a8", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ex_cldr, "~> 2.26", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:ex_cldr_currencies, "~> 2.13", [hex: :ex_cldr_currencies, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "5de180d21018797bc412aae727402b3004df4c5666ed2602863448993b035c9b"}, + "ex_cldr_territories": {:hex, :ex_cldr_territories, "2.4.0", "01e96157277e3ebf5dae242bbbe1c93096922acd0edc1a0d82f81d9ac11c06f0", [:mix], [{:ex_cldr, "~> 2.26", [hex: :ex_cldr, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "a57d182d2c934a91cc2157c5a0a201eb5659874578c12ef9cadcac6391d37b8a"}, + "ex_cldr_units": {:hex, :ex_cldr_units, "3.12.2", "407e67dc19ee78617332c1ee81c3b0859880b60eccb10a816e918c4848ae1d7a", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ex_cldr_lists, "~> 2.10", [hex: :ex_cldr_lists, repo: "hexpm", optional: false]}, {:ex_cldr_numbers, "~> 2.25", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:ex_doc, "~> 0.18", [hex: :ex_doc, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:ratio, "~> 2.4", [hex: :ratio, repo: "hexpm", optional: false]}], "hexpm", "db09db479e5b9139ef4b890bfc5acc0bcdc421a6b2a679c44ada0a35c63595b3"}, + "ex_doc": {:hex, :ex_doc, "0.28.2", "e031c7d1a9fc40959da7bf89e2dc269ddc5de631f9bd0e326cbddf7d8085a9da", [:mix], [{:earmark_parser, "~> 1.4.19", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "51ee866993ffbd0e41c084a7677c570d0fc50cb85c6b5e76f8d936d9587fa719"}, + "ex_money": {:hex, :ex_money, "5.9.0", "14ec07a0e950bc8ffdecfe3227e48010e7f97d1e12112f80cb62157ed8806373", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ex_cldr_numbers, "~> 2.23", [hex: :ex_cldr_numbers, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.0 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "9ef44a58b468f32d19f4707f81ead03f93d3e669cb0abda02e60aa6a927150d4"}, + "jason": {:hex, :jason, "1.3.0", "fa6b82a934feb176263ad2df0dbd91bf633d4a46ebfdffea0c8ae82953714946", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "53fc1f51255390e0ec7e50f9cb41e751c260d065dcba2bf0d08dc51a4002c2ac"}, + "makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"}, "makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"}, - "mime": {:hex, :mime, "2.0.1", "0de4c81303fe07806ebc2494d5321ce8fb4df106e34dd5f9d787b637ebadc256", [:mix], [], "hexpm", "7a86b920d2aedce5fb6280ac8261ac1a739ae6c1a1ad38f5eadf910063008942"}, - "nimble_parsec": {:hex, :nimble_parsec, "1.1.0", "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89", [:mix], [], "hexpm", "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"}, + "nimble_parsec": {:hex, :nimble_parsec, "1.2.3", "244836e6e3f1200c7f30cb56733fd808744eca61fd182f731eac4af635cc6d0b", [:mix], [], "hexpm", "c8d789e39b9131acf7b99291e93dae60ab48ef14a7ee9d58c6964f59efb570b0"}, "numbers": {:hex, :numbers, "5.2.4", "f123d5bb7f6acc366f8f445e10a32bd403c8469bdbce8ce049e1f0972b607080", [:mix], [{:coerce, "~> 1.0", [hex: :coerce, repo: "hexpm", optional: false]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "eeccf5c61d5f4922198395bf87a465b6f980b8b862dd22d28198c5e6fab38582"}, - "phoenix_html": {:hex, :phoenix_html, "3.0.4", "232d41884fe6a9c42d09f48397c175cd6f0d443aaa34c7424da47604201df2e1", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "ce17fd3cf815b2ed874114073e743507704b1f5288bb03c304a77458485efc8b"}, - "plug": {:hex, :plug, "1.12.1", "645678c800601d8d9f27ad1aebba1fdb9ce5b2623ddb961a074da0b96c35187d", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d57e799a777bc20494b784966dc5fbda91eb4a09f571f76545b72a634ce0d30b"}, - "plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"}, + "phoenix_html": {:hex, :phoenix_html, "3.2.0", "1c1219d4b6cb22ac72f12f73dc5fad6c7563104d083f711c3fcd8551a1f4ae11", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "36ec97ba56d25c0136ef1992c37957e4246b649d620958a1f9fa86165f8bc54f"}, "poison": {:hex, :poison, "4.0.1", "bcb755a16fac91cad79bfe9fc3585bb07b9331e50cfe3420a24bcc2d735709ae", [:mix], [], "hexpm", "ba8836feea4b394bb718a161fc59a288fe0109b5006d6bdf97b6badfcf6f0f25"}, "ratio": {:hex, :ratio, "2.4.2", "c8518f3536d49b1b00d88dd20d49f8b11abb7819638093314a6348139f14f9f9", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:numbers, "~> 5.2.0", [hex: :numbers, repo: "hexpm", optional: false]}], "hexpm", "441ef6f73172a3503de65ccf1769030997b0d533b1039422f1e5e0e0b4cbf89e"}, - "telemetry": {:hex, :telemetry, "0.4.3", "a06428a514bdbc63293cd9a6263aad00ddeb66f608163bdec7c8995784080818", [:rebar3], [], "hexpm", "eb72b8365ffda5bed68a620d1da88525e326cb82a75ee61354fc24b844768041"}, } diff --git a/mix/my_app_cldr.ex b/mix/my_app_cldr.ex index adedc47..150715e 100644 --- a/mix/my_app_cldr.ex +++ b/mix/my_app_cldr.ex @@ -1,6 +1,6 @@ defmodule MyApp.Cldr do use Cldr, locales: ["en", "th", "zh-Hant", "zh-Hans", "ar", "he"], + default_locale: "en", providers: [Cldr.Number, Cldr.Unit, Cldr.Territory, Cldr.LocaleDisplay] - -end \ No newline at end of file +end diff --git a/test/cldr_html_currency_test.exs b/test/cldr_html_currency_test.exs index 31fba0a..4a1ba8e 100644 --- a/test/cldr_html_currency_test.exs +++ b/test/cldr_html_currency_test.exs @@ -6,28 +6,28 @@ defmodule Cldr.HTML.Currency.Test do describe "currency_select/3" do test "with selected currency" do - string = safe_to_string( - Cldr.HTML.Currency.select( - :my_form, - :currency, - selected: :USD, - currencies: ~w(USD EUR JPY COP) - ) - ) - assert (string == ~s() + string = + safe_to_string( + Cldr.HTML.Currency.select( + :my_form, + :currency, + selected: :USD, + currencies: ~w(USD EUR JPY COP) + ) + ) - || string == - ~s() <> ~s() <> ~s() <> ~s() <> - ~s() <> ~s() - ) - + ~s() <> ~s() || + string == + ~s() end test "without selected currency" do @@ -46,27 +46,26 @@ defmodule Cldr.HTML.Currency.Test do end test "when selected currency is not in currencies" do - string = safe_to_string( - Cldr.HTML.Currency.select( - :my_form, - :currency, - selected: :USD, - currencies: ~w(EUR JPY) - ) - ) + string = + safe_to_string( + Cldr.HTML.Currency.select( + :my_form, + :currency, + selected: :USD, + currencies: ~w(EUR JPY) + ) + ) - assert (string == - ~s() <> ~s() <> ~s() <> - ~s() <> ~s() - || string == + ~s() <> ~s() || + string == ~s() - ) - + ~s() <> + ~s() <> + ~s() <> ~s() end test "with thai locale" do diff --git a/test/cldr_html_locale_test.exs b/test/cldr_html_locale_test.exs index dc6ba0c..f3c6c50 100644 --- a/test/cldr_html_locale_test.exs +++ b/test/cldr_html_locale_test.exs @@ -6,49 +6,51 @@ defmodule Cldr.HTML.Locale.Test do describe "locale_select/3" do test "with selected locale" do - string = safe_to_string( - Cldr.HTML.Locale.select( - :my_form, - :locale, - selected: "en", - locales: ~w(en ja ar zh-Hant zh-Hans) - ) - ) - assert string == - ~s{} + string = + safe_to_string( + Cldr.HTML.Locale.select( + :my_form, + :locale, + selected: "en", + locales: ~w(en ja ar zh-Hant zh-Hans) + ) + ) + assert string == + ~s{} end test "with identity localization" do - string = safe_to_string( - Cldr.HTML.Locale.select( - :my_form, - :locale, - locale: :identity - ) - ) - assert string == - ~s{} + string = + safe_to_string( + Cldr.HTML.Locale.select( + :my_form, + :locale, + locale: :identity + ) + ) + assert string == + ~s{} end test "with unknown identity locale ja" do assert Cldr.HTML.Locale.select(:my_form, :locale, locale: :identity, locales: ["ja"]) == - {:error, {Cldr.UnknownLocaleError, "The locale \"ja\" is not known."}} + {:error, {Cldr.UnknownLocaleError, "The locale \"ja\" is not known."}} end - end -end \ No newline at end of file +end diff --git a/test/cldr_html_territory_test.exs b/test/cldr_html_territory_test.exs index d1a638a..d0f087f 100644 --- a/test/cldr_html_territory_test.exs +++ b/test/cldr_html_territory_test.exs @@ -6,94 +6,102 @@ defmodule Cldr.HTML.Territory.Test do describe "territory_select/3" do test "with selected territory" do - string = safe_to_string( - Cldr.HTML.Territory.select( - :my_form, - :territory, - territories: [:US, :AU, :HK], - selected: :AU - ) - ) - assert string == - ~s() - + string = + safe_to_string( + Cldr.HTML.Territory.select( + :my_form, + :territory, + territories: [:US, :AU, :HK], + selected: :AU + ) + ) + assert string == + ~s() end test "with selected territory and short names" do - string = safe_to_string( - Cldr.HTML.Territory.select( - :my_form, - :territory, - territories: [:US, :AU, :HK], - selected: :AU, - style: :short - ) - ) + string = + safe_to_string( + Cldr.HTML.Territory.select( + :my_form, + :territory, + territories: [:US, :AU, :HK], + selected: :AU, + style: :short + ) + ) + assert string == - ~s() + ~s() end test "with selected territory and variant names" do - string = safe_to_string( - Cldr.HTML.Territory.select( - :my_form, - :territory, - territories: [:US, :CZ], - selected: :CZ, - style: :variant - ) - ) + string = + safe_to_string( + Cldr.HTML.Territory.select( + :my_form, + :territory, + territories: [:US, :CZ], + selected: :CZ, + style: :variant + ) + ) + assert string == - ~s() + ~s() end test "with locale" do - string = safe_to_string( - Cldr.HTML.Territory.select( - :my_form, - :territory, - territories: [:US, :AU], - selected: :IT, - locale: "th" - ) - ) + string = + safe_to_string( + Cldr.HTML.Territory.select( + :my_form, + :territory, + territories: [:US, :AU], + selected: :IT, + locale: "th" + ) + ) + assert string == - ~s() + ~s() end test "with locale and case insensitive unicode collator" do - string = safe_to_string( - Cldr.HTML.Territory.select( - :my_form, - :territory, - territories: [:US, :AU], - selected: :IT, - locale: "th", - collator: &(Cldr.Collation.sort(&1, casing: :insensitive)) - ) - ) + string = + safe_to_string( + Cldr.HTML.Territory.select( + :my_form, + :territory, + territories: [:US, :AU], + selected: :IT, + locale: "th", + collator: &Cldr.Collation.sort(&1, casing: :insensitive) + ) + ) + assert string == - ~s() + ~s() end end -end \ No newline at end of file +end diff --git a/test/cldr_html_unit_test.exs b/test/cldr_html_unit_test.exs index fdf0d5c..c7450b6 100644 --- a/test/cldr_html_unit_test.exs +++ b/test/cldr_html_unit_test.exs @@ -6,57 +6,61 @@ defmodule Cldr.HTML.Unit.Test do describe "unit_select/3" do test "with selected unit" do - string = safe_to_string( - Cldr.HTML.Unit.select( - :my_form, - :unit, - units: [:foot, :inch], - selected: :foot, - units: [:foot, :inch] - ) - ) - assert string == - ~s() + string = + safe_to_string( + Cldr.HTML.Unit.select( + :my_form, + :unit, + units: [:foot, :inch], + selected: :foot, + units: [:foot, :inch] + ) + ) + assert string == + ~s() end test "with selected unit and style" do - string = safe_to_string( - Cldr.HTML.Unit.select( - :my_form, - :unit, - units: [:foot, :inch], - selected: :foot, - style: :narrow, - units: [:foot, :inch] - ) - ) - assert string == - ~s() + string = + safe_to_string( + Cldr.HTML.Unit.select( + :my_form, + :unit, + units: [:foot, :inch], + selected: :foot, + style: :narrow, + units: [:foot, :inch] + ) + ) + assert string == + ~s() end test "with locale" do - string = safe_to_string( - Cldr.HTML.Unit.select( - :my_form, - :unit, - units: [:foot, :inch], - selected: :foot, - locale: "th" - ) - ) + string = + safe_to_string( + Cldr.HTML.Unit.select( + :my_form, + :unit, + units: [:foot, :inch], + selected: :foot, + locale: "th" + ) + ) + assert string == - ~s() + ~s() end end -end \ No newline at end of file +end