Answer the question
In order to leave comments, you need to log in
Let's play Ruby on Rails?
Yesterday, with a friend of CapeRatel , we had the following question:
Do not tell me how to display the class name translated into Russian in lower case from the @article object.
ru:
class_name_translate:
article: 'Статьи'
tags: 'Тэги'
def get_articles
@article = Article.all
@tag = Tag.all
@article_model_ru = translate_model_name(@article).mb_chars.downcase
@tag_model_ru = translate_model_name(@tag).mb_chars.downcase
end
private
def translate_model_name(obj)
I18n.t(obj.model_name.i18n_key, scope: :class_name_translate)
end
Answer the question
In order to leave comments, you need to log in
obj.model_name.human
And put the localization in ru.activerecord.models
I think Vsuhachev
understood correctly .
ru:
activerecord:
models:
article: 'Статьи'
tags: 'Тэги'
@article = Article.all
@article_model_ru = (@article.model_name.human).mb_chars.downcase
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question