【问题标题】:Configure I18n fallbacks on Heroku在 Heroku 上配置 I18n 回退
【发布时间】:2012-09-18 20:14:51
【问题描述】:

我已经尽一切努力在 Heroku 上制作 i18n 后备,但我做不到。 我不想收到“翻译缺失消息”。它在开发模式下工作正常。

请帮忙!

谢谢

require "i18n/backend/fallbacks"
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.fallbacks.map(:es => [:en])
config.i18n.fallbacks = true

【问题讨论】:

标签: ruby-on-rails ruby-on-rails-3 heroku internationalization i18n-gem


【解决方案1】:

在 config/enviroments/production.rb 中

class Appname::Application.configure do
  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found)
  config.i18n.fallbacks = true
end

how to use rails i18n fallback features

【讨论】:

    【解决方案2】:

    我的 application.rb 文件中有这个:

    config.i18n.fallbacks = [:en]
    

    我刚刚在 production.rb 中注释了这段代码:

    config.i18n.fallbacks = true
    

    它在 heroku 中对我来说工作正常。

    【讨论】:

    • 太棒了!评论 config.i18n.fallbacks = true 有帮助!
    猜你喜欢
    • 1970-01-01
    • 2018-06-25
    • 2014-04-18
    • 1970-01-01
    • 2011-04-10
    • 2020-06-02
    • 1970-01-01
    • 1970-01-01
    • 2012-01-23
    相关资源
    最近更新 更多