I have ajax devise forms that on error append field and message of error to the bottom of the form.
On ajax:error I do following:
$.each(errors, function(field, messages){
error_div.append(field + " " + "messages)
});
I want to translate the errors that are sent and for messages that devise generate I've found an answer on SO that works for me (adding it in my translation file):
en:
errors:
messages:
accepted: "have to be checked"
Now when I get an error it is like following:
terms_and_conditions have to be checked
So next on my list was somehow translating these modal attributes
So I found another SO post that explained a way to translate model attributes like following:
activerecord:
models:
recruiter:
terms_and_conditions: "Terms and conditions"
But I got a 501 server error, After tracing the bug and printing the error it is as following:
I18n::InvalidPluralizationData at /recruiters
=============================================
> translation data {:terms_and_conditions=>"TERMS TRANSLATION"} can not be used with :count => 1
app/controllers/recruiters/registrations_controller.rb, line 8
``` ruby
3
4 def create
5 respond_to do |format|
6 format.json {
7 build_resource(sign_up_params)
> 8 if resource.save
9 RegistrationMailer.recruiter(resource.id).deliver_later! if Rails.env.production?
10 sign_in(resource_name, resource)
11 if ['true', true].include?(params[:get_token])
12 token = resource.generate_authentication_token!
13 render json: { id: resource.id, email: resource.email, authentication_token: token }
So I looked for the error InvalidPluralizationData and found an answer that explained you need both singular and plural translations. So I changed I tried
activerecord:
models:
recruiter:
terms_and_conditions:
one: "Term and condition singular test"
other: "Term and conditions plural test"
But the same error still applies with different params:
I18n::InvalidPluralizationData at /recruiters
translation data {:company_name=>{:one=>"Term and condition singular test", :other=>"Term and conditions plural test"}} can not be used with :count => 1
I havent been able to find a suitable solution to also translate these model attributes without breaking the whole form (i'm not able to submit the form even if I try to translate the attributes).
Any help is greatly appreciated.