ironsand
ironsand

Reputation: 15151

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

I have text like this

config/locales/en.yml

record_your_voice: 'Record your voice?'

When I'm seeing the page in Japanese local config, the text Record Your Voice is shown - the capitalized left side of code.

How can I use the text "Record your voice?" when corresponding Japanese text failed.

Upvotes: 0

Views: 37

Answers (1)

Benjamin Bouchet
Benjamin Bouchet

Reputation: 13181

The answer is given here

in your application.rb file, you have the following options :

# 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'}

Upvotes: 2

Related Questions