Page 1 of 1

Translation

Posted: Mon Sep 03, 2018 3:02 pm
by marc
Hi,

I am looking for a way to translate the fields of a form into another language. I imagine it like this: If "French" is selected in a dropdown, the labels are translated into French. If "English" is selected, the default text is displayed. In other words, the language of the logged in user should not be used. The user selects the language of the form. Can I use the inbuilt translation for this?

Re: Translation

Posted: Wed Sep 12, 2018 4:43 am
by admin
marc,

You can try this...

Code: Select all



$("[id^='label_']").each(function( index ) {

   var h = $(this).html();
   var t = nuTranslate(h);
   
   $(this).html(t);

});

I find this page very helpful when using jQuery...

https://www.w3schools.com/jquery/jquery ... ectors.asp


Steven

Re: Translation

Posted: Wed Sep 12, 2018 5:47 am
by marc
Steven, how can I set the language using your code?

I select French, from the dropdown, the GUI elements are translated to French. The same for English.
And as mentioned above, this should work no matter what language the user has set.
lang.png

Re: Translation

Posted: Thu Sep 13, 2018 12:19 am
by admin
marc,

I didn't notice you say...
the language of the logged in user should not be used.
My way won't work for you.

The best thing you can do is create an array of Label names and the text to go in them - for each language.

Steven