Modules

filter

 

Objects/Functions

module (N/translation)

SuiteScript 2.0

Main Examples

N/translation Module
Member Type: Name
Search NetSuite - https://system.netsuite.com/app/help/helpcenter.nl?search=N/translation Module

// Code Example 1
// key HELLO_1 = 'Hello, {1}'

message: translation.get({
collection: 'custcollection_my_strings',
key: 'HELLO_1'
})({
params: ['NetSuite']
})

// Code Example 2
/**
* @NApiVersion 2.x
*/

require(['N/ui/message', 'N/translation'],
function(message, translation) {

// Create a message with translated strings
var myMsg = message.create({
title: translation.get({
collection: 'custcollection_my_strings',
key: 'MY_TITLE'
})(),
message: translation.get({
collection: 'custcollection_my_strings',
key: 'MY_MESSAGE'
})(),
type: message.Type.CONFIRMATION
});

// Show the message for 5 seconds
myMsg.show({
duration: 5000
});
});

// Code Example 3
/**
* @NApiVersion 2.x
*/

require(['N/ui/message', 'N/translation'],
function(message, translation) {

// Create a message with translated strings
var myMsg = message.create({
title: translation.get({
collection: 'custcollection_my_strings',
key: 'MY_TITLE',
locale: translation.Locale.COMPANY_DEFAULT
})(),
message: translation.get({
collection: 'custcollection_my_strings',
key: 'MY_MESSAGE',
locale: translation.Locale.COMPANY_DEFAULT
})(),
type: message.Type.CONFIRMATION
});

// Show the message for 5 seconds
myMsg.show({
duration: 5000
});
});

// Code Example 4
/**
* @NApiVersion 2.x
*/

require(['N/ui/message', 'N/translation'],
function(message, translation) {

// Create a message with translated strings
var myMsg = message.create({
title: translation.get({
collection: 'custcollection_my_strings',
key: 'MY_TITLE'
})(),
message: translation.get({
collection: 'custcollection_my_strings',
key: 'HELLO_1'
})({
params: ['NetSuite']
}),
type: message.Type.CONFIRMATION
});

// Show the message for 5 seconds
myMsg.show({
duration: 5000
});
});

// Code Example 5
/**
* @NApiVersion 2.x
*/

require(['N/ui/message', 'N/translation'],
function(message, translation) {

// Load translation strings by key
var localizedStrings = translation.load({
collections: [{
alias: 'myCollection',
collection: 'custcollection_my_strings',
keys: ['MY_TITLE', 'MY_MESSAGE']
}]
});

// Create a message with translated strings
var myMsg = message.create({
title: localizedStrings.myCollection.MY_TITLE(),
message: localizedStrings.myCollection.MY_MESSAGE(),
type: message.Type.CONFIRMATION
});

// Show the message for 5 seconds
myMsg.show({
duration: 5000
});
});

// Code Example 6
/**
* @NApiVersion 2.x
*/

require(['N/ui/message', 'N/translation'],
function(message, translation) {

// Load two Translation Collections
var localizedStrings = translation.load({
collections: [{
alias: 'myCollection',
collection: 'custcollection_my_strings',
keys: ['MY_TITLE']
},{
alias: 'myOtherCollection',
collection: 'custcollection_other_strings',
keys: ['MY_OTHER_MESSAGE']
}]
});

// Create a message with translated strings
var myMsg = message.create({
title: localizedStrings.myCollection.MY_TITLE(),
message: localizedStrings.myOtherCollection.MY_OTHER_MESSAGE(),
type: message.Type.CONFIRMATION
});

// Show the message for 5 seconds
myMsg.show({
duration: 5000
});
});

// Code Example 7
/**
* @NApiVersion 2.x
*/

require(['N/ui/message', 'N/translation'],
function(message, translation) {

// Load a Translation Collection and a set of locales
var germanStrings = translation.load({
collections: [{
alias: 'myCollection',
collection: 'custcollection_my_strings',
keys: ['MY_TITLE', 'MY_MESSAGE']
}],
locales: [translation.Locale.de_DE, translation.Locale.es_ES]
});

// Select a locale from the list of loaded locales
var spanishStrings = translation.selectLocale({
handle: germanStrings,
locale: translation.Locale.es_ES
});

// Create a message with translated strings
var myMsg = message.create({
title: germanStrings.myCollection.MY_TITLE(),
message: spanishStrings.myCollection.MY_MESSAGE(),
type: message.Type.CONFIRMATION
});

// Show the message for 5 seconds
myMsg.show({
duration: 5000
});
});

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