nilid
nilid

Reputation: 372

Globalize3 - two translations in one view

I use gem globalize3.

I want to get a translation posts in two languages​​, first in English and then in Russian in one index view. And I want to post that is not in English, was located below in Russian after the English posts. My problem is that since I have a default locale :en, and if:

@posts = Post.with_translations(:en)

I get posts in english as I need, if:

@posts_ru = Post.with_translations(:ru)

I get posts in english too..Probably because the default locale English

How I can get @posts in english and then in russian together in one index view? please help me! thanks in advance!

Upvotes: 1

Views: 852

Answers (1)

emrahbasman
emrahbasman

Reputation: 2013

You can get all translations like this:

@posts = Post.with_translations

And in your view use it like below:

<% @posts.each do |post| %>

  <%= post.name(:en) %>
  <%= post.name(:ru) %>

<% end %>

Upvotes: 6

Related Questions