How to translate UI Messages (sys_ui_message) with variables in the key?

Erik Gardner1
Giga Guru

Hi,

I'm translating Service Portal Widgets and I'm searching the HTML bodies for references to UI Messages which I then can create translation entries for.

Normally I take the text from a reference, ex. "show less" from ${show less} and add it as the key in my sys_ui_message entry, select language and then add the translation which works like a charm.

But in some cases the HTML references have variables within them. Ex: ${show all ({{teamMembers.length}})}.

How do I translate these kind of messages?

 

find_real_file.png

 

find_real_file.png

1 ACCEPTED SOLUTION

H_kon Sm_rvik
Kilo Expert

I recently translated the pagination text in the widget 'Widget Data Table'. Below is the HTML-code which is translated.

${Rows {​{data.window_start + 1}} - {​{ mathMin(data.window_end,data.row_count) }} of {​{data.row_count}}}

Surprisingly the key for this bit, was

Key: Rows {​{data.window_start + 1}} - {​{ mathMin(data.window_end,data.row_count) }} of {​{data.row_count}}
Message: Rader {{data.window_start + 1}} - {{ mathMin(data.window_end,data.row_count) }} av {{data.row_count}}

In your case the key is probably

Show all ({{teamMembers.length}})

I found a property you can set to auto detect missing translations. 'glide.translate.learn'. One caveat about this is it will generate thousands of translations ending with [lang code], in my case my instance was filled with a ton of [no].

You can read more about the property here

Alternative, which gives a bit more granularity.

View solution in original post

4 REPLIES 4

Chuck Tomasi
Tera Patron

If it works like most other message translation constructs, the parameters will be replaced with whatever is inside the message field's numbered parameters.

Example:

 

Save ({0})

 

will be translated as 

 

Save (4)

 

Haven't tried this in Service Portal, but that's how it works in the other places I use messages.

Erik Gardner1
Giga Guru

Thanks for your answer, Chuck!

 

So if I came across this variable: ${show all ({{teamMembers.length}})}

 

Should my UI Message key looke like this?

find_real_file.png

 

One set of curly braces.

show all ({0})

and 

visa alla ({0})

 

H_kon Sm_rvik
Kilo Expert

I recently translated the pagination text in the widget 'Widget Data Table'. Below is the HTML-code which is translated.

${Rows {​{data.window_start + 1}} - {​{ mathMin(data.window_end,data.row_count) }} of {​{data.row_count}}}

Surprisingly the key for this bit, was

Key: Rows {​{data.window_start + 1}} - {​{ mathMin(data.window_end,data.row_count) }} of {​{data.row_count}}
Message: Rader {{data.window_start + 1}} - {{ mathMin(data.window_end,data.row_count) }} av {{data.row_count}}

In your case the key is probably

Show all ({{teamMembers.length}})

I found a property you can set to auto detect missing translations. 'glide.translate.learn'. One caveat about this is it will generate thousands of translations ending with [lang code], in my case my instance was filled with a ton of [no].

You can read more about the property here

Alternative, which gives a bit more granularity.