Neil Middleton
Neil Middleton

Reputation: 22240

Loading specific translations with Globalize3

Is it possible to load a specific translation with Globalize 3?

For instance, I have a Post which is translatable and shows on the front end in the correct locale as it should. However, I want to show a this same version in the admin which has a fixed locale of :en.

One way of doing this seems to be by telling what locale we're in:

Globalize.locale = :de
Post.where(id: params[:id])

works just fine, but that's going to be overriding the locale globally.

So, how can I request the specific locale for just this one instance?

Upvotes: 2

Views: 268

Answers (1)

Neil Middleton
Neil Middleton

Reputation: 22240

You need to use Globalize.with_locale in the view:

- Globalize.with_locale(:de) do
  = debug @post

Upvotes: 1

Related Questions