对应语言文本不存在时如何使用英文文本

How to use English text when corresponding language text doesn't exist

我有这样的文字

config/locales/en.yml

record_your_voice: 'Record your voice?'

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

对应日文字失败时如何使用"Record your voice?"文字

给出答案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'}