File tree Expand file tree Collapse file tree 2 files changed +7
-35
lines changed
activesupport/lib/active_support Expand file tree Collapse file tree 2 files changed +7
-35
lines changed Original file line number Diff line number Diff line change @@ -35,22 +35,11 @@ class FileUpdateChecker
35
35
# have directories as keys and the value is an array of extensions to be
36
36
# watched under that directory.
37
37
#
38
- # This method must also receive a block that will be called once a path changes.
39
- #
40
- # == Implementation details
41
- #
42
- # This particular implementation checks for added, updated, and removed
43
- # files. Directories lookup are compiled to a glob for performance.
44
- # Therefore, while someone can add new files to the +files+ array after
45
- # initialization (and parts of Rails do depend on this feature), adding
46
- # new directories after initialization is not supported.
47
- #
48
- # Notice that other objects that implement the FileUpdateChecker API may
49
- # not even allow new files to be added after initialization. If this
50
- # is the case, we recommend freezing the +files+ after initialization to
51
- # avoid changes that won't make effect.
38
+ # This method must also receive a block that will be called once a path
39
+ # changes. The array of files and list of directories cannot be changed
40
+ # after FileUpdateChecker has been initialized.
52
41
def initialize ( files , dirs = { } , &block )
53
- @files = files
42
+ @files = files . freeze
54
43
@glob = compile_glob ( dirs )
55
44
@block = block
56
45
Original file line number Diff line number Diff line change @@ -9,25 +9,6 @@ class Railtie < Rails::Railtie
9
9
config . i18n . load_path = [ ]
10
10
config . i18n . fallbacks = ActiveSupport ::OrderedOptions . new
11
11
12
- def self . reloader
13
- @reloader ||= ActiveSupport ::FileUpdateChecker . new ( reloader_paths ) { I18n . reload! }
14
- end
15
-
16
- def self . reloader_paths
17
- @reloader_paths ||= [ ]
18
- end
19
-
20
- # Add <tt>I18n::Railtie.reloader</tt> to ActionDispatch callbacks. Since, at this
21
- # point, no path was added to the reloader, I18n.reload! is not triggered
22
- # on to_prepare callbacks. This will only happen on the config.after_initialize
23
- # callback below.
24
- initializer "i18n.callbacks" do |app |
25
- app . reloaders << I18n ::Railtie . reloader
26
- ActionDispatch ::Reloader . to_prepare do
27
- I18n ::Railtie . reloader . execute_if_updated
28
- end
29
- end
30
-
31
12
# Set the i18n configuration after initialization since a lot of
32
13
# configuration is still usually done in application initializers.
33
14
config . after_initialize do |app |
@@ -63,7 +44,9 @@ def self.initialize_i18n(app)
63
44
64
45
init_fallbacks ( fallbacks ) if fallbacks && validate_fallbacks ( fallbacks )
65
46
66
- reloader_paths . concat I18n . load_path
47
+ reloader = ActiveSupport ::FileUpdateChecker . new ( I18n . load_path . dup ) { I18n . reload! }
48
+ app . reloaders << reloader
49
+ ActionDispatch ::Reloader . to_prepare { reloader . execute_if_updated }
67
50
reloader . execute
68
51
69
52
@i18n_inited = true
You can’t perform that action at this time.
0 commit comments