P
P
Philipp2014-09-22 16:09:24
Ruby on Rails
Philipp, 2014-09-22 16:09:24

How to fix localization?

Installed gem 'russian', set localization.
Created corresponding entries in ru.yml

ru:
  activerecord:
    models:
      company:
              one: "Компания"
              two: "Компании"
              other: "Компании"

View
<%- model_class = Company -%>
<div class="page-header">
  <h1><%=t '.title', :default => model_class.model_name.human.pluralize.titleize %></h1>
</div>

A is given to Company s . How to do it right?
And I also want to add declensions. For example: Add a company . How it's done?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
vsuhachev, 2014-09-22
@vsuhachev

To use the abbreviation '.title' you need to write in localization like this

ru:
  имя_контроллера:
    имя_действия:
      title:
        one: Компания
        other: Компании

and in the view like this
t('.title', count: 2)

D
dexdev, 2014-09-28
@AdilA

doing so

<%= @post.count %> <%= Russian.p(@post.count, 'просмотр', 'просмотра', 'просмотров') %>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question