如果不存在相应的语言文本,如何使用英文文本

时间:2015-12-30 23:20:09

标签: ruby-on-rails internationalization

我有这样的文字

配置/区域设置/ en.yml

record_your_voice: 'Record your voice?'

当我在日语本地配置中看到该页面时,会显示文本Record Your Voice - 代码的大写左侧。

如何使用“录制你的声音?”文字?当相应的日文文本失败时。

1 个答案:

答案 0 :(得分:2)

答案是here

在您的application.rb文件中,您有以下选项:

# rails will fallback to config.i18n.default_locale translation 
config.i18n.fallbacks = true

# rails will fallback to en, no matter what is set as config.i18n.default_locale 
config.i18n.fallbacks = [:en]

# fallbacks value can also be a hash - a map of fallbacks if you will
# missing translations of es and fr languages will fallback to english
# missing translations in german will fallback to french ('de' => 'fr')
config.i18n.fallbacks = {'es' => 'en', 'fr' => 'en', 'de' => 'fr'}