在Rails中临时禁用i18n后退

mdr*_*iel 8 ruby-on-rails internationalization globalize2 ruby-on-rails-3

I18n后备加载:

 I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
Run Code Online (Sandbox Code Playgroud)

现在有什么想法暂时禁用它吗?我有表单,我想编辑各种语言版本,并且使用后备我得到默认语言的字段,如果给定的翻译还没有.

Jep*_*erg 0

您使用全球化吗?

我对系统字符串使用 I18n 回退,对属性翻译使用 globalize3。我希望系统字符串回退,而不是属性。我只是用一个小猴子补丁禁用了全球化的后备:

配置/初始化程序/i18n.rb:

require "i18n/backend/fallbacks" 
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)

# monkey patch globalize3 to not use fallbacks
module Globalize
  def self.fallbacks?
    false
  end
end
Run Code Online (Sandbox Code Playgroud)