Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Widget Connector
width60%
urlhttp://www.youtube.com/watch?v=bVMjCP2fBZM&feature=youtu.be

MultiLangCode_861.js

MultiLanguageForm_861.nitro_s


There have been many requests to be able to change an item's label dynamically. A common use case might be creating a multi-lingual form where you can change the item labels to the user's selected language.

...

In the Form onLoad event add:

Code Block
languagejs
var srv = form.getServiceConfiguration('SC_GetStrings');

...


srv.connectEvent("onCallFinished", function(success)

...


{

...


if(success) {

...


app.getSharedData().strings = JSON.parse(BO.F_Paragraphtext.getValue());

...


}

...


});


  • You will have to change 'SC_GetStrings' to the ID of your service, if you change it from this instruction.

  • You will have to change the 'BO.F_Paragraphtext' to the ID of the text field if you change it from this instruction.

...

5. Determine how you are going to toggle the language and call the function to cause the labels to change.  The example below sets the titles based on a language passed to the function as the result of toggling a radio selection.

Code Block
languagejs
app.getSharedData().setLanguage(BOA.getValue());

You could also change the language by reading a URL parameter:

Code Block
var lang = "English"; //defaults to English

...


var urlP = app.getUrlParameter("lang");

...


if(typeof urlP !== "undefined") {

...


  lang = urlP;

...


}

...


app.getSharedData().setLanguage(lang);

The second set of steps will require that you enter all of your language strings into the “host” application that has been provided with this example. I will provide a few comments on how the form is used.

...