Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eb9dbf4

Browse filesBrowse files
committed
Yield loaded translations to block in #load_translations
This makes introspecting the translations loaded by a file easier. Maintains backwards compatability as the block is optional.
1 parent 9ec31b0 commit eb9dbf4
Copy full SHA for eb9dbf4

File tree

Expand file treeCollapse file tree

1 file changed

+6
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-1
lines changed
Open diff view settings
Collapse file

‎lib/i18n/backend/base.rb‎

Copy file name to clipboardExpand all lines: lib/i18n/backend/base.rb
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ module Base
1313
# for details.
1414
def load_translations(*filenames)
1515
filenames = I18n.load_path if filenames.empty?
16-
filenames.flatten.each { |filename| load_file(filename) }
16+
filenames.flatten.each do |filename|
17+
loaded_translations = load_file(filename)
18+
yield filename, loaded_translations if block_given?
19+
end
1720
end
1821

1922
# This method receives a locale, a data hash and options for storing translations.
@@ -226,6 +229,8 @@ def load_file(filename)
226229
raise InvalidLocaleData.new(filename, 'expects it to return a hash, but does not')
227230
end
228231
data.each { |locale, d| store_translations(locale, d || {}, skip_symbolize_keys: keys_symbolized) }
232+
233+
data
229234
end
230235

231236
# Loads a plain Ruby translations file. eval'ing the file must yield

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.