Permalink
Browse files

set `i18n.enforce_available_locales` before `i18n.default_locale`.

  • Loading branch information...
1 parent d71c1fc commit 73b57a515f650595b21b9f26b4a5a3c9c982691e @senny senny committed Dec 5, 2013
@@ -1,3 +1,8 @@
+* Ensure `config.i18n.enforce_available_locales` is set before any other
+ configuration option.
+
+ *Yves Senn*
+
* Added `Date#all_week/month/quarter/year` for generating date ranges.
*Dmitriy Meremyanin*
@@ -31,6 +31,11 @@ def self.initialize_i18n(app)
fallbacks = app.config.i18n.delete(:fallbacks)
+ if app.config.i18n.has_key?(:enforce_available_locales)
+ # this option needs to be set before `default_locale=` to work properly.
+ I18n.enforce_available_locales = app.config.i18n.delete(:enforce_available_locales)
+ end
+
app.config.i18n.each do |setting, value|
case setting
when :railties_load_path
@@ -183,5 +183,16 @@ class Foo < ActiveRecord::Base
load_app
assert_fallbacks ca: [:ca, :"es-ES", :es, :'en-US', :en]
end
+
+ test "config.i18n.enforce_available_locales is set before config.i18n.default_locale is" do
+ add_to_config <<-RUBY
+ config.i18n.default_locale = :it
+ config.i18n.enforce_available_locales = true
+ RUBY
+
+ assert_raises(I18n::InvalidLocale) do
+ load_app
+ end
+ end
end
end

0 comments on commit 73b57a5

Please sign in to comment.