0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

How to force a language in Rails | i18n

Last updated at Posted at 2019-04-16

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

Rails | i18n で 言語を強制指定する方法

About

About this translattion

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?