本文翻译自:Rails I18n validation deprecation warning
I just updated to rails 4.0.2 and I'm getting this warning: 我刚刚更新到rails 4.0.2并且我收到此警告:
[deprecated] I18n.enforce_available_locales will default to true in the future. [已弃用] I18n.enforce_available_locales将来默认为true。 If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. 如果您确实想跳过语言环境的验证,可以设置I18n.enforce_available_locales = false以避免此消息。
Is there any security issue in setting it to false? 将其设置为false是否存在任何安全问题?
#1楼
参考:https://stackoom.com/question/1NQw8/Rails-I-n验证弃用警告
#2楼
Doesn't seem that way - that'd be previous behavior of the way i18n works - new behavior (true) will raise an error when you ask for a locale not implemented/available. 似乎不是这样 - 这是i18n工作方式的先前行为 - 当您要求未实现/可用的区域设置时,新行为(true)将引发错误。
See the commit that added this warning: https://github.com/svenfuchs/i18n/commit/3b6e56e06fd70f6e4507996b017238505e66608c 请参阅添加此警告的提交: https : //github.com/svenfuchs/i18n/commit/3b6e56e06fd70f6e4507996b017238505e66608c
#3楼
Just for completeness, note that you can also get rid of the warning by setting I18n.enforce_available_locales
to true
(or false
) in config/application.rb
: 为了完整I18n.enforce_available_locales
,请注意您也可以通过在config/application.rb
I18n.enforce_available_locales
设置为true
(或false
)来消除警告:
require File.expand_path('../boot', __FILE__)
.
.
.
module SampleApp
class Application < Rails::Application
.
.
.
I18n.enforce_available_locales = true
.
.
.
end
end
#4楼
I18n.config.enforce_available_locales = true
在Rails 3.2.16中为我工作(我把它放在config / application.rb中)
#5楼
Important : Make sure your app is not using I18n 0.6.8, it has a bug that prevents the configuration to be set correctly . 重要提示 :确保您的应用未使