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   
Comments
Post a Comment