Modules

filter

 

Objects/Functions

module (N/translation)

SuiteScript 2.0

translation.load(options)

{translation}.load({collections: {alias: {string*},collection: {string*},keys: {string[]*}},locales: {string[]}})

N/translation Module
translation.load()
Method Description: Creates a translation.Handle object with translations for the specified Translation Collections and locales. This method returns a translation.Handle object with translation strings organized by collection and ID. Every node in a translation.Handle object is either another translation.Handle object or a translation.Translator function. You can load translation strings from multiple Translation Collections in a single call of translation.load(options). You must specify the keys of individual translation strings that you want to load. You cannot load all of the terms in a Translation Collection at one time. The translation.load(options) method can load a maximum of 1,000 translation strings, regardless of whether the strings are loaded from one collection or multiple collections. When you load translation strings using translation.load(options), you can specify a list of valid locales for the strings. You can use these locales when you select a locale using translation.selectLocale(options). If you specify more than one locale when you call translation.load(options), the first specified locale in the list is used for the created translation.Handle object. If you want to use a different locale from the list, use translation.selectLocale(options), which returns a translation.Handle object in the specified locale. You must load a locale using translation.load(options) before you can select it using translation.selectLocale(options).
Returns: translation.Handle
Supported Script Types: Client and server-side scripts For additional information, see SuiteScript 2.0 Script Types.
Governance: None
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.load(options)

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

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