How do I translate the on/off toogle button?

Hello,

I hope you can help me.
I want to translate the text of the toogle button from yes/ no too the language which is selected.

let toogleText = {de: ['Ja', 'Nein'], pl: ['Tak', 'Nie'], cs: ['Ano', 'Ne']};
let toggleButton = {DeleteStreet: toogleText, DeleteHousenumber: toogleText, DeletePObox: toogleText, DeletePostalcodePObox: toogleText, DeleteEmail: toogleText, 
DeleteIBAN1: toogleText,  DeleteIBAN2: toogleText};

function translateToogleButton() {
    Object.entries(toggleButton).forEach(([key, value]) => {
        if (fd.field(key).value === true){
            fd.field(key).$el.textContent = value[userLang][0];
        } else if (fd.field(key).value === false){
            fd.field(key).$el.textContent = value[userLang][1];
        }
    });
}

translateToogleButton();

The code works except this line and it does this.

fd.field(key).$el.textContent

image

How can I fix it? It should look like this but with other language inside.
image
Maybe something like this?

fd.field(key).$el.on

Best regards
Stern

Hello @Sternchen,

This can be done using this code:

// change the widget's configuration
fd.field('Toggle').widget.setOptions({
    messages: {
        checked: "YES",
        unchecked: "NO"
    }
});

Thanks that helped alot. :slight_smile:
I was searching for hours.
Just a little other question.
Is it possible to make the toggle a little bigger? So you can read the full message?
Because it looks like this.

image

Best regards
Sternchen

@Sternchen,

This is the code to change the toggle width:

fd.field('Toggle').widget.setOptions({
    width: 140
});

Please learn more about widget customizations in the documentation here:
https://plumsail.com/docs/forms-sp/designer/sp-fields/yes-no.html#cnfigure-widget