Translations for Hidden NG-Templates

Alex Winkley
Tera Contributor

Hi all,

 

I have a unique situation where I'm attempting to translate our Service Portal UI for a non-OOB language, so I have to set up all translations myself. I have been successful for the most part, however there are a few pieces of the portal that use ng-templates to load the HTML, and those ng-templates aren't always visible to us as admins so ServiceNow can protect their core code. I used i18n debugging to verify the translations I'm trying to load are UI Messages, but the issue is that unless I see the HTML itself, it can be very tedious to figure out the correct formatting for dynamic messages (for example, timestamps like "36 m ago" or "2 hours from now"). Does anyone have recommendations for the best way to figure out what the UI Message key values should be in these cases besides trial and error?

 

1 ACCEPTED SOLUTION

-O-
Kilo Patron
Kilo Patron

What I do is to install a 3rd language and look up and figure out the keys with its help.

 

That is because - as far as I can tell - template are not localized as widgets are.

While widget Body HTML templates are processed server side, so ${ } tokens can be replaces, a template could be loaded/added using various methods of which none is processed server side, so it would be tough to replace ${ } tokens.

Most of the time what happens is that in the Server script of widgets messages are stored translated on data and the template just uses the translated (or not) message arriving from server side.

View solution in original post

7 REPLIES 7

Alex Winkley
Tera Contributor

That's extremely helpful - thank you for the insight!

You're most welcome 🙂

Alex Winkley
Tera Contributor

Replying to the solution to give the context of how I ended up finding the translations.

ServiceNow has a few javascript libraries it loads in the platform which are accessible to all users. These libraries can be found at [your instance]/js_includes.js and [your instance]/js_includes_sp.js

 

I ended up finding the template (attachment_list.xml) and found the translation I was looking for (in this case the time that has past since an attachment was uploaded for the attachment widget). The format is as follows:

settings.strings = {
	ago: msgs['%d ago'],
	fromNow: msgs['%d from now'],
	justNow: msgs["just now"],
	seconds: msgs["less than a minute"],
	minute: msgs["about a minute"],
	minutes: msgs["%d minutes"],
	hour: msgs["about an hour"],
	hours: msgs["about %d hours"],
	day: msgs["a day"],
	days: msgs["%d days"],
	month: msgs["about a month"],
	months: msgs["%d months"],
	year: msgs["about a year"],
	years: msgs["%d years"],
	today: msgs["today"],
	wordSeparator: msgs["timeago_number_separator"],
	numbers: []
};