solved by I18n.config.enforce_available_locales = false
, then I18n will not try :language locale.
Rails 4 I18n incorrectly recognize locale :'language-conuntry' as :'language' like :'zh-CN' as :zh
-
19-06-2023 - |
Frage
for example Rails will treat :'zh-CN'
as :zh
in config/application.rb
config.i18n.fallbacks = [:'zh-CN'] # or ['zh-CN'.to_sym]
ActionView::Helpers::FormBuilder#label will raise
:zh is not a valid locale
I am using Rails 4.1.0.rc1, Ruby 2.1.1 and keep gems latest.
Lösung
Andere Tipps
You can set available_locales. Setting enforce_available_locales
to false you are turning off the errors instead of adding your language to available_locales.
If you need language zh
to be available, just add it to available_locales.
Example:
config.i18n.available_locales = [:"zh-CN", :zh]
try this
config.i18n.fallbacks = [:"zh-CN"]
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow