在设置enforce_available_locales = true之后,Rails I18n验证弃用警告

giv*_*nse 9 localization rails-i18n ruby-on-rails-4

你放了这样的东西 config/application.rb

I18n.enforce_available_locales = true                                        
config.i18n.load_path += Dir[Rails.root.join('config/locales/', '*.{rb,yml}').to_s]
config.i18n.available_locales = ['es-LA', :en]                               
config.i18n.default_locale = 'es-LA'
Run Code Online (Sandbox Code Playgroud)

警告仍然出现:

[deprecated] I18n.enforce_available_locales will default to true in the future.
Run Code Online (Sandbox Code Playgroud)

giv*_*nse 12

原因是由于语言环境具有语言国家格式的错误.好消息是它已经修好了.这在Github中报告了问题13164并且用拉取请求229修复.

如果你想使用修复程序获取最新代码,请像这样更新gem:

使用以下命令更新您的Gemfile:

gem 'i18n', github: 'svenfuchs/i18n'
Run Code Online (Sandbox Code Playgroud)

然后: bundle install