Translate model name by string in Rails -


there 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 yaml:

ru:   activerecord:     exceptions:       not_found: "%{model_name} не найден" 

as can see have russian text in translation, model name still in english. how can translate model name in russian too? in advance!

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 

http://guides.rubyonrails.org/i18n.html


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -