2

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?

Neil Middleton
  • 22,105
  • 18
  • 80
  • 134

1 Answers1

1

You need to use Globalize.with_locale in the view:

- Globalize.with_locale(:de) do
  = debug @post
Neil Middleton
  • 22,105
  • 18
  • 80
  • 134