Permalink
Browse files

Ensure it works with empty locale files.

  • Loading branch information...
1 parent 188d924 commit 8805e01c42c434bf3885b42a7e1afbc3315d2442 @josevalim josevalim committed Jun 23, 2010
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/i18n/backend/base.rb
  2. +5 −0 test/i18n_load_path_test.rb
  3. +1 −0 test/test_data/locales/empty.yml
View
@@ -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
@@ -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')
@@ -0,0 +1 @@
+en:

0 comments on commit 8805e01

Please sign in to comment.