Skip to content

Commit

Permalink
Ensure it works with empty locale files.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Jun 23, 2010
1 parent 188d924 commit 8805e01
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/i18n/backend/base.rb
Expand Up @@ -202,7 +202,7 @@ def load_file(filename)
type = File.extname(filename).tr('.', '').downcase
raise UnknownFileType.new(type, filename) unless respond_to?(:"load_#{type}")
data = send(:"load_#{type}", filename) # TODO raise a meaningful exception if this does not yield a Hash
data.each { |locale, d| store_translations(locale, d) }
data.each { |locale, d| store_translations(locale, d || {}) }
end

# Loads a plain Ruby translations file. eval'ing the file must yield
Expand Down
5 changes: 5 additions & 0 deletions test/i18n_load_path_test.rb
Expand Up @@ -16,6 +16,11 @@ def test_nested_load_paths_do_not_break_locale_loading
assert_equal "baz", I18n.t(:'foo.bar')
end

def test_load_empty_yml_works
I18n.load_path = [[locales_dir + '/empty.yml']]
assert_equal "baz", I18n.t(:default => "baz")
end

def test_adding_arrays_of_filenames_to_load_path_do_not_break_locale_loading
I18n.load_path << Dir[locales_dir + '/*.{rb,yml}']
assert_equal "baz", I18n.t(:'foo.bar')
Expand Down
1 change: 1 addition & 0 deletions test/test_data/locales/empty.yml
@@ -0,0 +1 @@
en:

0 comments on commit 8805e01

Please sign in to comment.