Translation

6 views
Skip to first unread message

Jahyr Moreno

unread,
May 9, 2018, 10:16:45 PM5/9/18
to Regula
How can I translate the validationResults array?
Message has been deleted

Jahyr Moreno

unread,
May 9, 2018, 11:55:02 PM5/9/18
to Regula
Well, sometimes with a little research, dedication and passion some things are achieved. For example, as an interim solution this is what I have done:

var validationResults = regula.validate();

for(var i = 0; i < validationResults.length; i++) {

   
var validationResult = validationResults[i];
   
   
switch (validationResult.message) {
       
case "The text field cannot be blank.":
            validationResults
[i].message = "La fecha no puede estar vacía.";
           
break;
       
case "The text field is required.":
            validationResults
[i].message = "Este campo es obligatorio.";
           
break;
       
case "undefined cannot be blank.":
            validationResults
[i].message = "La cantidad no puede estar vacía.";
           
break;
       
case "undefined is required.":
            validationResults
[i].message = "La cantidad es obligatoria.";
           
break;
       
case "undefined can only contain numbers.":
            validationResults
[i].message = "La cantidad solo puede contener números.";
           
break;
       
case "undefined needs to be greater than or equal to 1.":
            validationResults
[i].message = "La cantidad debe ser mayor o igual a 1.";
           
break;
   
}


In some cases I use "undefined", because I know I will receive that error message, since I used the validator, in an <input type = "number"> and the error message when It can not verify the "input" type It writes it as "undefined". So I also took the opportunity to translate the name you have on the form, which is "cantidad".
Reply all
Reply to author
Forward
0 new messages