You can specify locale:
option.
Example: To specify English (: en)
I18n.t('message', locale: :en) # => It is English
Example: To specify Japanese (: ja)
I18n.t('message', locale: :ja) # => これは日本語です
Premise
It is assumed that it is in the following state.
English file
en: message: It is English
File for Japan
ja: message: これは日本語です
trap
By the way, it is a mistake to write as follows.
I18n.t('en.message') # => "translation missing: en.en.message"
I18n.t('ja.message') # => "translation missing: ja.ja.message"
environment
- Rails 4.0.0
- i18n 0.7.0
Original by
About
チャットメンバー募集
何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。