Skip to content

Instantly share code, notes, and snippets.

@pashagray
Created June 11, 2021 04:20
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pashagray/a90f35465ca5b2377941b335804485b4 to your computer and use it in GitHub Desktop.
Save pashagray/a90f35465ca5b2377941b335804485b4 to your computer and use it in GitHub Desktop.
Simple script to detect and load new files for config/locales without reload rails server
# config/initializers/reload_locale.rb
if Rails.env == 'development'
locale_reloader = ActiveSupport::FileUpdateChecker.new(Dir["config/locales/*yml"]) do
I18n.backend.reload!
end
ActionDispatch::Callbacks.to_prepare do
locale_reloader.execute_if_updated
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment