I am using rails internationalization api for activerecord translations .I am having trouble translating error messages. How to translate multiple error messages from different files in my project?I am have files named application_draft.rb,team.rb,user.rb,todo.rb
inside my models
folder.I want to translate error messages in them ,here's my en.yml
file:
errors:
models:
-team:
-application_draft:
-conference:
-todo:
-user:
attributes:
roles:
too_many_reviewers: too many reviewers
multiple_sel_error: must not be selected twice
must_accepted: must have been accepted
one_app_allowed: Only one application may be lodged
confirmed_email_address: Please make sure every student confirmed the email address.
wrong_date_sel: must be a later date than start date
no_more_than_two: "there cannot be more than 2 students on a team."
cannot_changed: can't be changed
I have implemented this code and throws error(means it did not work). Here's my one of application_draft.rb
and todo.rb
error code snippets:
application.rb:
def different_projects_required
if project1 && project1 == project2
errors.add(:projects, :multiple_sel_error)
end
end
todo.rb
def validate_number_of_reviewers
errors.add(:user, :too_many_reviewers) if application.todos.count > 3
end
end
How to translate these both avoiding duplication errors?
Aucun commentaire:
Enregistrer un commentaire