Do all the locale scripts have to run on install and upgrade?

AI-generated summary

The discussion revolves around the issue of running all locale scripts during installation and upgrade, which can be time-consuming. Alexander_Wright and codinghorror express their desire to skip these files or restrict the set of locales installed.

Sam suggests that compiling all languages every time the setting is changed would add complexity, and instead proposes holding off on engineering until Sprockets is replaced sam. codinghorror proposes using an environment variable to skip locale compilation unless specified.

Mittineague mentions a deprecation warning related to Sprockets, which codinghorror notes is a source of pain and slows down rebuilds. Sam promises to prioritize improvements to this process sam.

pimusaraj updates that while locales are still being compiled on rebuild, the process is now faster due to improvements in compression, resulting in 25% faster rebuilds.

Running all the locale scripts seems to take a long time when installing or upgrading.

Is it possible to restrict the set of locales that are installed?

I wish it would skip these files too. I think we need to replace Sprockets before we can do that right @sam?

Sort of, the trouble is that when locale is switched in admin we would have to compile an asset conditionally, this would add a reasonable amount of complexity

Why not compile all languages every time that setting is changed?

Then at least you pay the penalty at time of switch rather than all the time forever and constantly…

Another alternative is to only compile the set locale at rebuild and run a background task to compile the others? (no idea if this is feasible, just a thought that ran through my mind)

It is doable but has risks, for one we don’t have a system that is able to do any background work on site setting change and notify UI when done (double needed when user locale is enabled), I would hold off on all engineering here till we get rid of sprockets.

Another option is env variable that must be set for any locale other than English, so we can skip all that work unless env is set. Maybe ask user at command line if they plan to ever use any other langs.

A bit off-topic

I won’t concern myself with worrying about my seeing these

DEPRECATION WARNING: Sprockets method `register_engine` is deprecated.
Please register a mime type using `register_mime_type` then
use `register_compressor` or `register_transformer`.
https://github.com/rails/sprockets/blob/master/guides/extending_sprockets.md#supporting-all-versions-of-sprockets-in-processors

This is still the source of much pain and makes rebuilds very slow due to all the locales that sites are not using, but yet every single locale has to be processed on every rebuild @sam.

Yes, I am bumping this to the front of @pmusaraj list next week. We have many plans of improving this and got to make it happen.

Locales are still being compiled on rebuild, but the process is now faster due to some improvements in how they are compressed (which was taking the most time on rebuilds). On the most basic DO instance, for example, precompiling each locale takes less than 0.1 seconds now.

Rebuilds are now about 25% faster, on my test DO instance the rebuild takes 4m50s (compared to about 7m previously).