Skip to content

Commit

Permalink
Remove deprecation of enforce_available_locales and default it to true
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosantoniodasilva committed Jul 19, 2014
1 parent 5e1ce48 commit b5703d7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
- Setting `:default_exception_hander` Symbol to `I18n.exception_handler`.
- `normalize_translation_keys` in favor of `normalize_keys`.
- `:rescue_format` option on the exception handler.
- `enforce_available_locales` now defaults to true with no deprecation message.
9 changes: 0 additions & 9 deletions lib/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ def locale_available?(locale)

# Raises an InvalidLocale exception when the passed locale is not available.
def enforce_available_locales!(locale)
handle_enforce_available_locales_deprecation

if config.enforce_available_locales
raise I18n::InvalidLocale.new(locale) if !locale_available?(locale)
end
Expand Down Expand Up @@ -338,12 +336,5 @@ def normalize_key(key, separator)
def normalized_key_cache
@normalized_key_cache ||= Hash.new { |h,k| h[k] = {} }
end

def handle_enforce_available_locales_deprecation
if config.enforce_available_locales.nil? && !defined?(@unenforced_available_locales_deprecation)
$stderr.puts "[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message."
@unenforced_available_locales_deprecation = true
end
end
})
end
7 changes: 4 additions & 3 deletions lib/i18n/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ def load_path=(load_path)
@@load_path = load_path
end

# [Deprecated] this will default to true in the future
# Defaults to nil so that it triggers the deprecation warning
# Whether or not to verify if locales are in the list of available locales.
# Defaults to true.
@@enforce_available_locales = true
def enforce_available_locales
defined?(@@enforce_available_locales) ? @@enforce_available_locales : nil
@@enforce_available_locales
end

def enforce_available_locales=(enforce_available_locales)
Expand Down

4 comments on commit b5703d7

@rubys
Copy link

@rubys rubys commented on b5703d7 Jul 20, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing the following failure: http://intertwingly.net/projects/AWDwR4/checkdepot/section-15.2.html

Git bisect:

b5703d7431ecfc1b99409e16c6590448570718ac is the first bad commit
commit b5703d7431ecfc1b99409e16c6590448570718ac
Author: Carlos Antonio da Silva <[email protected]>
Date:   Fri May 9 11:56:10 2014 -0300

    Remove deprecation of enforce_available_locales and default it to true

:100644 100644 1981e6d8389335c8f868e4c2b8fbe66d2da6dbc3 4e49fc52947d64e1dd41f498d29062223836b04b M      CHANGELOG.md
:040000 040000 a8b9c4559bd76e9e55a39a73c23fb893935ca873 407035fd634a0055f908d663677cd83cff201a30 M      lib
bisect run success

@carlosantoniodasilva
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take a look, thanks.

@rubys
Copy link

@rubys rubys commented on b5703d7 Jul 20, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rubys
Copy link

@rubys rubys commented on b5703d7 Jul 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #275

Please sign in to comment.