Service Portal: Widget Client Controller Translation

Sujatha V M
Kilo Patron
Kilo Patron

Hi,

I'm facing a problem where I'm unable to translate a text/content in Client controller script of a widget (Homepage Search)

I have used ng-bind:data.greeting instead of options.title in HTML

HTML code:

find_real_file.png

For e.g. I'm trying to translate the greeting message "Welcome" but unable to get it done.

Script:

find_real_file.png

Can anyone help me on this?

Please mark this as helpful and accept it as a solution if this resolves your query.
Sujatha V.M.
1 ACCEPTED SOLUTION

ChrisBurks
Mega Sage

If you have a message translation for "Welcome" then one of these ways should do it.



Option 1:


translate_options_1.png



Option 2:



translation_options_2.png



Or if you weren't using ngBind then you could also use the "${}" within the HTML template:


<h1>${Welcome} {{ user.first_name }}</h1>



The "${}"   and/or gs.getMessage() is what tells the system to do the translation.


View solution in original post

8 REPLIES 8

hashwanthalla
ServiceNow Employee
ServiceNow Employee

instead of a static text can we also translate the text that is pointed to a variable using option 1 ?

@hashwanthalla- Are you able to give an example of how you're trying to use the variable?

@ChrisBurks  confirmationMessage = ("your appointment ")- coming from server

 

and in client controller can we do this -> "${confirmationMessage}"  will this translate "your appointment" text ?

If confirmationMessage is a variable I don't think that it will. Have you tried it?

I believe the translation happens in the HTML markup field. Where behind the scenes either before rendering or while rendering there is code looking for ${ } encapsulation. When it finds this it converts the text between it.

Thus in the client controller I don't think there is anything that will negate the what comes between quotes after an assignment operator.

In your example "confirmationMessage" is a string and will be printed out as confirmationMessage unless you have a translation for the string confirmationMessage.