Rails I18n验证弃用警告

本文翻译自: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 . 重要提示 :确保您的应用未使

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值