Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure it works with empty locale files.

  • Loading branch information...
commit 8805e01c42c434bf3885b42a7e1afbc3315d2442 1 parent 188d924
@josevalim josevalim authored
View
2  lib/i18n/backend/base.rb
@@ -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
View
5 test/i18n_load_path_test.rb
@@ -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')
View
1  test/test_data/locales/empty.yml
@@ -0,0 +1 @@
+en:
Please sign in to comment.
Something went wrong with that request. Please try again.