Modules

filter

 

Objects/Functions

module (N/translation)

SuiteScript 2.0

translation.Handle

// Please search https://system.netsuite.com/app/help/helpcenter.nl?search=translation.Handle for more information.

N/translation Module
translation.Handle
Object Description: Encapsulates a Translation Collection for a locale. Use translation.load(options) to create a translation.Handle object with translations for the specified Translation Collections and locales. Use translation.selectLocale(options) to create a translation.Handle object in the specified locale from an existing translation.Handle object. The translation.Handle object is a hierarchical object, which means that each node in the object is either another translation.Handle object or a translation.Translator function. Translator functions combine strings with parameters. When you create a Translation Collection in the NetSuite UI, you can include parameter placeholders in your translation strings. The translator function injects the specified parameter values into the placeholders in the returned translation string.
Supported Script Types: Client and server-side scripts For additional information, see SuiteScript 2.0 Script Types.
Module: N/translation Module
Sibling Object Members: N/translation Module Members
Since: 2019.1
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=translation.Handle

Example:

// Code Example 1
// Add additional code
//...
var localizedStrings = translation.load({
collections: [{
alias: 'myCollection',
collection: 'custcollection_my_strings',
keys: ['MY_TITLE', 'MY_MESSAGE']
}]
});

var myMsg = message.create({
title: localizedStrings.myCollection.MY_TITLE(),
message: localizedStrings.myCollection.MY_MESSAGE(),
type: message.Type.CONFIRMATION
});
//...
// Add additional code

// Code Example 2
/**
* @NApiVersion 2.0
* @NScriptType clientscript
*/
define(['N/translation'], function(translation) {
return {
pageInit: function(context) {
var handle = translation.load({
collections: [
{alias: "phrases", collection: "CUSTCOLLECTION_PHRASES",
keys: ["HELLO"]},
{alias: "specialstrings", collection: "CUSTCOLLECTION_SPECIALSTRINGS",
keys: ["HELLO_1"]}
],
locales: ["fr_FR", 'en_US'] });
console.log(handle.phrases.HELLO());
//logs hello in company default language - Hello (if default is English)
var frenchHandle = translation.selectLocale({handle: result, locale: "fr_FR"});
console.log(frenchHandle.phrases.HELLO());
//logs hello in french - Bonjour
}
};
//...
// Add additional code

//SOURCE: https://system.netsuite.com/app/help/helpcenter.nl?fid=section_1541705125.html