Reputation: 12189
There is the following code:
model_name = self.class.name.demodulize.sub("Controller", "").singularize
message = t('activerecord.exceptions.not_found', model_name: model_name)
render json: message, status: :not_found
And there is some YAML:
ru:
activerecord:
exceptions:
not_found: "%{model_name} не найден"
As you can see I have Russian text in translation, but model name is still in English. How can I translate model name in Russian too? Thanks in advance!
Upvotes: 1
Views: 1160
Reputation: 102026
ru:
activerecord:
models:
user: пользователь
model_name = self.class.name.demodulize.sub("Controller", "").singularize
model_klass = model_name.constantize
message = t(
'activerecord.exceptions.not_found',
model_name: model_klass.model_name.human
)
render json: message, status: :not_found
Upvotes: 1