MrYawe

MrYawe

The problem

Every time we run mix gettext.extract it recompiles our app to extract gettext messages (that’s normal) but it also recompiles the cldr backend module which is slow to compiles (more than 10s).

Can we do something to avoid cldr backend module recompilation? I don’t think this should be needed here.

How to reproduce

We can easily reproduce this with a new phoenix app and the last elixir version (1.16.2):

mix phx.new my_app --database sqlite3

Add these deps:

{:ex_cldr, "~> 2.38"},
{:ex_cldr_messages, "~> 1.0"}

Add a backend module:

defmodule MyApp.Cldr do
  use Cldr,
    locales: ["en", "de", "es", "fr", "it", "ja", "ko", "nl", "pt", "zh"],
    default_locale: "en",
    providers: [Cldr.Message]
end

Add this configuration in config.exs:

config :ex_cldr,
  default_backend: MyApp.Cldr

And now every time you run mix gettext.extract you will see:

Compiling 16 files (.ex)
Generating MyApp.Cldr for 11 locales named [:de, :en, :es, :fr, :it, ...] with a default locale named :en

What I’ve tested so far

I know that deps are only compiled once so I’ve made a small experiment: instead of putting our cldr backend module in our app, I’ve put it as local deps.

mix.exs:

{:my_app_cldr, path: "./my_app_cldr"}

config.exs:

config :ex_cldr,
  default_backend: MyAppCldr

Then in the my_app_cldr subfolder, generated using mix new my_app_cldr:

mix.exs:

defp deps do
  [
    {:ex_cldr, "~> 2.38"},
    {:ex_cldr_messages, "~> 1.0"},
  ]
end
defmodule MyAppCldr do
  use Cldr,
    locales: ["en", "de", "es", "fr", "it", "ja", "ko", "nl", "pt", "zh"],
    default_locale: "en",
    providers: [Cldr.Message]
end

And.. it seems to work :smile:
MyAppCldr is only compiled once as a deps and then I can use this module in my app but I don’t know if it’s recommended to use cldr this way.

Showing Posts 1 to 3

03juan

03juan

Long story short: no, it’s doing a full recompilation of your app:
https://github.com/elixir-gettext/gettext/blob/main/lib/mix/tasks/gettext.extract.ex#L106-L126

alexslade

alexslade

How has your experience been using Cldr like this? Did you hit any issues?

kip

kip

ex_cldr Core Team

I’ve not heard of any issues using this approach (no issues logged in GitHub and I’ve seen no other references here on the forum or slack). And I can’t see any particular reason is shouldn’t work either than if you also configure the :gettext option in your CLDR backend module. In that case you would probably have to force compile the local dependency to pick up any gettext configuration changes.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews