translation of select box LOV field using catalog client script

Priyansh_98
Tera Guru

Hi,

 

we are using select box field in catalog form, in that select box we have to display different LOV's as per the company data. so for showing those i am using a catalog client script to add and remove option from the select box, but when the end user using different language on portal than on that time also LOV displays in english language, it does not translates.

below is my code to add and remove option from select box field

 

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    g_form.removeOption('supplier_subtype', 'Foreigner');
    g_form.removeOption('supplier_subtype', 'Individual');
    g_form.removeOption('supplier_subtype', 'Small Business');
    g_form.removeOption('supplier_subtype', 'Corporate');
    g_form.removeOption('supplier_subtype', 'None of the Above');
    if (newValue == '81ac26d8dbaefa005d625434ce9619c5' || newValue == '0f9c5b07dbd51b40bc31c170ba9619dc') {
        g_form.addOption('supplier_subtype', 'Individual', ('Individual'));
        g_form.addOption('supplier_subtype', 'Corporate', 'Corporate');
        g_form.addOption('supplier_subtype', 'None of the Above', 'None of the above');
    } else {
        g_form.addOption('supplier_subtype', 'Foreigner', 'Foreigner');
        g_form.addOption('supplier_subtype', 'Individual', 'Individual');
        g_form.addOption('supplier_subtype', 'Small Business', 'Small Business');
        g_form.addOption('supplier_subtype', 'None of the Above', 'None of the above');
    }
}

 

 

 

i tried using getmessage(); also but it is not working .

can any one help me with that??

Thanks, in advance

2 REPLIES 2

Deepak Shaerma
Kilo Sage

Hi @Priyansh_98 
Step 1: Define Messages
Go to application navigator, go to the System UI > Messages module and create entries for all your options in all the supported languages.

For example, add entries like:
- Key: Foreigner, Message: Foreigner (English)
- Key: Foreigner, Message: Extranjero (Spanish)
- Key: Individual, Message: Individual (English)
- Key: Individual, Message: Individuo (Spanish)

Step 2: Modify your scriptt

 

 

// Define your options dynamically
    var options = [];
    if (newValue == '81ac26d8dbaefa005d625434ce9619c5' || newValue == '0f9c5b07dbd51b40bc31c170ba9619dc') {
        options = [
            { value: 'Individual', label: getMessage('Individual') },
            { value: 'Corporate', label: getMessage('Corporate') },
            { value: 'None of the Above', label: getMessage('None of the above') }
        ];
    } else {
        options = [
            { value: 'Foreigner', label: getMessage('Foreigner') },
            { value: 'Individual', label: getMessage('Individual') },
            { value: 'Small Business', label: getMessage('Small Business') },
            { value: 'None of the Above', label: getMessage('None of the Above') }
        ];
    }
    
    // Add the appropriate options
    for (var j = 0; j < options.length; j++) {
        g_form.addOption('supplier_subtype', options[j].value, options[j].label);
    }
}

 

Please mark this response helpful or Accepted Solution, if this helps you in understand the requirement. This will Help both the community and me.
Thanks,
Deepak Sharma


Hi @Deepak Shaerma ,

 

I have tried your solution, but it is not working.

i am translating LOV's in Trad. Chinese language, i have also created entries in message table. but the data is not fetching from the message table itself.

 

Priyansh_98_0-1721031042104.png