How to translate widget title and placeholder in different language?

janhavipatil
Kilo Contributor

Hi Experts,

We are translating the service portal to Finnish language. we are facing problem in translating some customized widget titles and also the default placeholder available in search widget on homepage.

Here are screenshots. Highlighted part is not getting translated.

find_real_file.png

find_real_file.png

Thanks & Regards,

Janhavi

3 REPLIES 3

denis hoffmann
Kilo Guru

Hi Janhavi,

      1. in your customised "Latest News" widget,

in "Body HTML Template",  how do you call the Message Key for translation of your title ?

With something like that ? :

 <h4 class="panel-title">${Latest News}</h4>

if so, then in your sys_ui_message table,

add a new message

  •    Key = Latest News
  •    Language = Finnish
  •    Message = uusimmat uutiset

 

   2. and for "Homepage Search" widget , who is linked to "Typeahead Search" widget :

the placeholder text" How can we help?" in the input field, use value of c.option.title.

 

In its'Client controler" text area, you'll find :

c.options.title = c.options.title || c.data.searchMsg;

=> so you can define a title, as an option.

in your "Index" portal page ( or your custom version),
look into the "How can we Help ?" instance of "Homepage Search" widget.
=> You can set another text value as option , in the "Additional options, JSON format"  text area.

{
	"typeahead_search": {
		"value": "{title: 'Something different than How can we help?', size: 'lg', color: 'default'}",
		"displayValue": "{title: 'Something different than How can we help?', size: 'lg', color: 'default'}"
	}
}

or better , add ${ } quotes, to use getMessage translation :

{
	"typeahead_search": {
		"value": "{title: '${How can we help?}', size: 'lg', color: 'default'}",
		"displayValue": "{title: '${How can we help?}', size: 'lg', color: 'default'}"
	}
}

 

 

If it's empty, it'll use default value  stored in data.searchMsg.

 

Note : The ootb " Homepage Search" widget define a default_value title in its "Option schema" text area:

[{"name":"typeahead_search","default_value":"{title: 'How can we help?', size: 'lg' ...

 

Edit : Update 🙂 

according to https://docs.servicenow.com/bundle/kingston-servicenow-platform/page/build/service-portal/concept/c_... ,

instead of typing directly in "Additional options, JSON format" of the widget Instance, or cloning OOTB Widget to change 'Option schema', 
you can directly set your Additional option by editing it in 'Service Portal Designer' :

    - Go to 'Service Portal Designer',

    - edit 'Index' page,  ( or custom page)

    - click on Edit (Pen icon) for the "Homepage Search" Widget

    - in 'Typeahead Search' field, cut & paste default value : 
               {title: 'How can we  help?', size: 'lg', color: 'default'}
    - then change it to :
               {title: '${How can we  help?}', size: 'lg', color: 'default'}

 

In short :

this widget use c.option.title for the placeholder text.

c.options.title = c.options.title || c.data.searchMsg;

In order, it looks for

    1st - "Advanced option" title, set in JSON in the widget instance. This title override default value. You can define here a personalized message key.

   2nd - if no option set in the instance, then it'll use "default option" title from the widget, set in option schema.

   3rd - and if this default title is missing too  ( because deleted, for exemple), it'll use alternative text from data.searchMsg.

( with data.searchMsg = gs.getMessage("Search");   from  "Typeahead Search" widget server script )

Hi,

This doesn't seem to work anymore in the Paris release.

Anyone can confirm this ?

Or knows how to resolve ?