Getting the session language via a catalog client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2018 08:02 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2018 08:16 AM
Hi,
Once you have the language plugin installed. Go to the wrench icon and change the language preference to the language that you want to change the label for. Go to the catalog item in the changed language and go edit the label of the options within the select variable. It will automatically store the translated text in the table. You can verify it by checking the catalog item in both English and other language later.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 06:44 AM
Hi @Wayne Richmond, Did you found any way to do the translation? I have the same issue.