0
我想添加一個美國地區的特定區域設置護欄,但是告訴我,:en_locale
不是一個語言環境的有效代碼。我怎樣才能包含這個特定的區域?如何將特定區域的區域添加到Rails?
在app/config/locales
,我有en.yml
和en-US.yml
。
我application.rb
,我有以下幾點:
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
config.i18n.available_locales = [:en, :'en-US']
config.i18n.default_locale = :en
config.i18n.fallbacks = [:en]
# config.i18n.fallbacks = {:'zh-MY' => :'zh-CN'} # If we want to designate a lang to fallback to
錯誤消息:
I18n::InvalidLocale - :en_us is not a valid locale:
i18n (0.6.9) lib/i18n.rb:288:in `enforce_available_locales!'
i18n (0.6.9) lib/i18n/config.rb:11:in `locale='
actionview (4.1.14.2) lib/action_view/lookup_context.rb:239:in `locale='
actionview (4.1.14.2) lib/action_view/rendering.rb:19:in `locale='
i18n (0.6.9) lib/i18n.rb:35:in `locale='