Skip to content

Commit 7ff8f9a

Browse files
krekotenSven Fuchs
authored andcommitted
Make sure file names are always flattened
1 parent c9259ca commit 7ff8f9a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/i18n/backend/base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ module Base
1111
# plain Ruby (*.rb) or YAML files (*.yml). See #load_rb and #load_yml
1212
# for details.
1313
def load_translations(*filenames)
14-
filenames = I18n.load_path.flatten if filenames.empty?
15-
filenames.each { |filename| load_file(filename) }
14+
filenames = I18n.load_path if filenames.empty?
15+
filenames.flatten.each { |filename| load_file(filename) }
1616
end
1717

1818
# This method receives a locale, a data hash and options for storing translations.

test/backend/simple_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ def setup
4242
assert_equal expected, translations
4343
end
4444

45+
test "simple load_translations: given file names as array it does not raise anything" do
46+
assert_nothing_raised { I18n.backend.load_translations(["#{locales_dir}/en.rb", "#{locales_dir}/en.yml"]) }
47+
end
48+
4549
# storing translations
4650

4751
test "simple store_translations: stores translations, ... no, really :-)" do

0 commit comments

Comments
 (0)