Getting the session language via a catalog client script

Wayne Richmond
Tera Guru

I have created an onChange catalog client script that populates a select box on a catalog item:

 

function onChange(control, oldValue, newValue, isLoading) {

if (isLoading || newValue == '') { 
g_form.clearOptions('u_subcategory'); 
g_form.addOption('u_subcategory', '', '-- None --'); 
return; 
}
var icat = g_form.getValue('category');

if (icat == 'Example1') {
g_form.clearOptions('u_subcategory'); 
g_form.addOption('u_subcategory', '', '-- None --'); 
}

if (icat == 'Example2') {
g_form.clearOptions('u_subcategory'); 
g_form.addOption('u_subcategory', '', '-- None --');
g_form.addOption('u_subcategory', 'An example 1', 'An example 1'); 
g_form.addOption('u_subcategory', 'An example 2', 'An example 2'); 
}
}

I now need to translate the labels based on the user's language. What is the easiest way to achieve this? I had hoped creating a Translated Text record would work but I'm not that lucky.

I've seen a similar post where the dev created a Script Includes and called it from the client script, however I haven't seen the actual script and lack the knowledge to write one myself. Can anyone offer their expertise please?