spirito_libero
spirito_libero

Reputation: 1322

How can I see translations for the specific language in rails console? Using I18n?

I can see translations for the default language using the Rails console using this code:

I18n.t('views.signup.company_info')

But how can I see translations for the german language?

Upvotes: 0

Views: 393

Answers (2)

Ravi Teja Dandu
Ravi Teja Dandu

Reputation: 476

I18n.with_locale(:de) {I18n.t('views.signup.company_info')}

If you want to use a specific language for translation in a code block you can do this:

I18n.with_locale(locale) do
  your_code
end

Upvotes: 1

spirito_libero
spirito_libero

Reputation: 1322

For displaying the translation for the specific language we need to set the locale:

I18n.t('views.signup.company_info', locale: :de)

Upvotes: 2

Related Questions