PERF: Compile main locale bundles just-in-time (#32335)

Previously all locale bundles would be built & compressed during
assets:precompile. For most sites, only one of these languages was
actually used, so this is fairly wasteful.

This commit moves the main locale bundle into the
ExtraLocalesController, which has recently undergone many improvements
to make it more efficient. This allows locale files to be bundled "just
in time" when they're first accessed.

Now that brotli level=6 is enabled for these assets in our nginx config,
this change should have no impact on the locale bundle size.
This commit is contained in:
David Taylor
2025-04-28 10:31:27 +01:00
committed by GitHub
parent 3b9d9f5893
commit c62a4a4759
68 changed files with 37 additions and 317 deletions

View File

@ -1429,7 +1429,6 @@ class Plugin::Instance
""
opts[:server_locale_file] = Dir["#{root_path}/config/locales/server*.#{locale}.yml"].first ||
""
opts[:js_locale_file] = File.join(root_path, "assets/locales/#{locale}.js.erb")
locale_chain = opts[:fallbackLocale] ? [locale, opts[:fallbackLocale]] : [locale]
lib_locale_path = File.join(root_path, "lib/javascripts/locale")
@ -1522,8 +1521,7 @@ class Plugin::Instance
def valid_locale?(custom_locale)
File.exist?(custom_locale[:client_locale_file]) &&
File.exist?(custom_locale[:server_locale_file]) &&
File.exist?(custom_locale[:js_locale_file]) && custom_locale[:moment_js]
File.exist?(custom_locale[:server_locale_file]) && custom_locale[:moment_js]
end
def find_locale_file(locale_chain, path)