diff --git a/lib/i18n/backend/base.rb b/lib/i18n/backend/base.rb index 7ca9c28a..6e7c7df1 100644 --- a/lib/i18n/backend/base.rb +++ b/lib/i18n/backend/base.rb @@ -244,7 +244,7 @@ def load_file(filename) # Loads a plain Ruby translations file. eval'ing the file must yield # a Hash containing translation data with locales as toplevel keys. def load_rb(filename) - translations = eval(IO.read(filename), binding, filename) + translations = eval(IO.read(filename), binding, filename.to_s) [translations, false] end diff --git a/test/i18n/load_path_test.rb b/test/i18n/load_path_test.rb index 7d0d27a1..ab354c08 100644 --- a/test/i18n/load_path_test.rb +++ b/test/i18n/load_path_test.rb @@ -31,4 +31,14 @@ def setup I18n.load_path << Dir[locales_dir + '/*.{rb,yml}'] assert_equal "baz", I18n.t(:'foo.bar') end + + test "adding Pathnames to the load path does not break YML file locale loading" do + I18n.load_path << Pathname.new(locales_dir + '/en.yml') + assert_equal "baz", I18n.t(:'foo.bar') + end + + test "adding Pathnames to the load path does not break Ruby file locale loading" do + I18n.load_path << Pathname.new(locales_dir + '/en.rb') + assert_equal "bas", I18n.t(:'fuh.bah') + end end