Translation using getMessage for addOption choices is not working in catalog view.

si21
Tera Guru

Hi,

I am facing problem with variable choice translation in catalog view(portal).

Previously variable question and its choices are added using catalog client scripts (addoption). In order to translate those choices I have added getMessage to choices and created record in sys_ui_message table.

1.when I open the recordproducer: I see above 2 options in english.(not getting translated)

 

2.when selected general leave Inquiry, another field appears with options( not getting translated)

3. But when I change my selection to leaves and change back to general leave Inquiry, the dependent field appears with translated values.

What is the reason behind this behaviour. Please help me understand.

Thanks in advance. refer below the catalog client script used.

4 REPLIES 4

Alex Coope - SN
ServiceNow Employee
ServiceNow Employee

Siri, 

Not sure why, but your images don't appear to be working for me,

With regards to choices, you shouldn't need to call getMessage as the choices are intended to be associated to the field type / variable type and thus are entries in the [sys_choice] table collated via a "sys_choice_set" entry (with values per language). They shouldn't be added purely by script, because it's a lot of unnecessary admin overhead (thus not good technical practice) coupled with script maintenance to add a new value,

The details on the intended variable type is here, so the idea would be after you've made your English choices, you then add your other language choices (of translate the Record Producer via the Localization Framework, which would handle that). The system then understands what per language choices to present the user based on their user session language,

This image isn't an explicit example, but it should help explain what I mean (the variable in my example is called "choice_direction"):


Many thanks,
Kind regards

 

--------------------------------------------------------------------
Director of Globalization Deployment, Internationalization

Hi Alex, 

Even I am unable to see the image you mentioned in the reply. I have used addOption in catalog client script because choices should appear as per the user country and getMessage to transalte them. I'm sharing my images again. Please look in to this find_real_file.pngfind_real_file.pngfind_real_file.png

 

 

Alex Coope - SN
ServiceNow Employee
ServiceNow Employee

Siri, 

Yeah I think there might have been an issue with images yesterday,

So, there shouldn't be any need to be using script to add options because of the language to be shown, coupled with choices aren't supposed to be getMessage() calls, as they are typically records in the sys_choice table,

Depending on how you've made the English choices there are two options:

  1. If you are creating the choices for English in the [sys_choice] table, then you just need to add the translations as records in the [sys_choice] table as I detail in this nugget video from a webinar here,

  2. If you have made the choice as a "Question Choice" on the variable directly, then the "text" entry of the choice would be translated via an entry in the [sys_translated] table. This can be done quite simply via using the Localization Framework as I show in this nugget here,

Ultimately, with the translations in the right place, the system is clever enough to understand which to show based on the users language preference,


Many thanks,
Kind regards

--------------------------------------------------------------------
Director of Globalization Deployment, Internationalization

Hi @Alex Coope - SN ,

 

As per you first suggestion, if we want to translate none option then how it will work because we are adding value empty in None option?

 

Thanks,

Brijmohan