You are viewing limited content. For full access, please sign in.

Question

Question

How can you translate the field prompts of required fields in LF Forms?

asked on February 24, 2014

Our organization requires our forms available in two official languages. To accomplish this, we are creating two copies of each form and translating one manually to keep terminology accurate rather than trusting a web translator.

 

However, we have been unsuccessful when attempting to translate the form prompts in required fields (please see the attached image).

If anybody has any experience with this or can suggest a more simple solution, it would be much appreciated. Thanks! 

Capture.GIF
Capture.GIF (18.6 KB)
0 0

Answer

APPROVED ANSWER
replied on February 24, 2014

Those tooltips, otherwise known as Constraint Validations are not generated by Laserfiche Forms - they are generated by the form itself being set as a required field and your browser's reaction to them. So if your browser is XYZ language primarily then the default Constraint Validation will be too!

 

Here's a helpful link as well for the how's and why's of this. It will actually look different depending on the screen you are looking at. 

 

If the language of the browser on the machine is in french, this is what it will look like:

 

 

 

1 0

Replies

replied on February 24, 2014 Show version history

There currently isn't an easy way to do that because those messages are generated on-the-fly. However, I wrote some code that does dynamic client-side translation using a third-party translation library.

 

var fr_dictionary = {
  
  'Please fill in this field.': "Remplissez ce domaine, s'il vous plaît.",
  
}

$(document).ready(function() {
  

  //load the jQuery-i18n library

  $.when(
    
    $.getScript( "https://raw.github.com/recurser/jquery-i18n/master/jquery.i18n.js" ),
    $.Deferred(function( deferred ){
    $( deferred.resolve );
    })
    ).done(function(){
  
        $.i18n.load(fr_dictionary);
    
	    $('.cf-field input, .cf-field textarea, .cf-field select').blur(function() {
      
  		
            //look for a warning box and translate it if there is one

            if ($('.ws-po-box')[0]){
    
  	        $('.ws-po-box').text($.i18n._('Please fill in this field.'));
  	    
            }
      
       });
    });
  
});

You can copy/paste this code into the JavaScript portion of your Form and it should work. I tested it on mine and did not notice any problems (see attachment). If you do plan on using it though, I recommend downloading the third-party library from GitHub and hosting it on your Forms server, and loading it from there.

 

Note that the message for required dropdown fields is actually different, but I just lumped those under the same translation. If you want to translate that accurately too, add it to the fr_dictionary variable as a key-value pair and then call it inside another event handler function for dropdown fields (.cf-field select).

translation.png
2 0
You are not allowed to follow up in this post.

Sign in to reply to this post.