elixir-cldr / cldr

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

The `data_dir` param seems to be ignored #123

Closed erikreedstrom closed 5 years ago

erikreedstrom commented 5 years ago

It seems that data_dir is being ignored. Our config is used within an umbrella app, and defines an otp_app param.

defmodule MyApp.Cldr do
  @moduledoc false
  use Cldr, otp_app: :my_app, default: "en"
end
config :my_app, MyApp.Cldr,
  locales: ~w(ca da en es fi fr it nb nl pt ru sv),
  data_dir: "./priv/cldr",
  providers: [Cldr.Number]

No matter what we do, setting in the module or in the config, it always downloads to the app priv dir. We're thinking it's likely related to the order of pattern matching here: https://github.com/kipcole9/cldr/blob/dc37a0565dc7bc2be680b31953001f7ab031d09b/lib/cldr/config/config.ex#L198-L204

Strangely, when we removed the otp_app param and defined everything in the module, we couldn't tell where the cldr was being downloaded to. ~It seemed that wasn't working at all.~ Rereading the docs it seems these were going to ex_cldr priv?

The reason this is important for us is that we use the cldr data in multiple applications. With this current issue, we are downloading the same data multiple times.

kipcole9 commented 5 years ago

@erikreedstrom Yes, that's clearly not good. I'll try to get it fixed tonight but it may take until Friday.

kipcole9 commented 5 years ago

@erikreedstrom As of this commit I believe that the :data_dir configuration is working correctly. I have added some tests and additional notes in the @doc.

Would you consider testing this version from the GitHub repo before I push the release to hex?

client_data_dir

Return the path name of the CLDR data directory for a client application.

The order of priority to determine where the client data directory is located is:

kipcole9 commented 5 years ago

Pushed to hex as version 2.6.1

erikreedstrom commented 5 years ago

@kipcole9 Sorry it took so long to get back to you. 🙇 Can confirm this works great. Thanks again!