问题
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!
回答1:
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 %>
来源:https://stackoverflow.com/questions/12142347/globalize3-two-translations-in-one-view