Reputation: 163
There are some locale files in our project, that look like:
notice: '%{resource_name} was successfully created.'
alert: '%{resource_name} could not be created.'
We use I18n for translation. Now if we translate something in Russian, it looks this way:
notice: '%{resource_name} был успешно создан.'
Where %{resource_name} is default translation and is always in English. How can i translate this to other languages, using my own translation? Thank you!
Upvotes: 2
Views: 704
Reputation: 1581
I assume your resource is an Active Record model ? If so please check this part of documentation.
Create translation file:
ru:
activerecord:
models:
user: пользователь
then:
t('notice', resource_name: User.model_name.human)
Upvotes: 1
Reputation: 23989
You could have a different translation for each controller and actions, e.g.
en:
posts:
create:
notice: "Post was successfully created"
users:
create:
notice: "User was successfully created"
And so on
Upvotes: 0