Skip to content

Commit

Permalink
Don't execute i18n watcher on boot.
Browse files Browse the repository at this point in the history
It shouldn't catch any file changes initially, and unnecessarily slows
down boot of applications with lots of translations.
  • Loading branch information
gmcgibbon committed Oct 10, 2024
1 parent f1be11a commit ab7b58b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions activesupport/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* Don't execute i18n watcher on boot. It shouldn't catch any file changes initially,
and unnecessarily slows down boot of applications with lots of translations.

*Gannon McGibbon*

* Fix `ActiveSupport::HashWithIndifferentAccess#stringify_keys` to stringify all keys not just symbols.

Previously:
Expand Down
3 changes: 1 addition & 2 deletions activesupport/lib/active_support/i18n_railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@ def self.initialize_i18n(app)
directories = watched_dirs_with_extensions(reloadable_paths)
root_load_paths = I18n.load_path.select { |path| path.to_s.start_with?(Rails.root.to_s) }
reloader = app.config.file_watcher.new(root_load_paths, directories) do
I18n.load_path.delete_if { |p| p.to_s.start_with?(Rails.root.to_s) && !File.exist?(p) }
I18n.load_path.delete_if { |path| path.to_s.start_with?(Rails.root.to_s) && !File.exist?(p) }
I18n.load_path |= reloadable_paths.flat_map(&:existent)
end

app.reloaders << reloader
app.reloader.to_run do
reloader.execute_if_updated { require_unload_lock! }
end
reloader.execute
end

@i18n_inited = true
Expand Down

0 comments on commit ab7b58b

Please sign in to comment.