translation.Translator

Object / Function Description

Represents a translator function that returns translated strings.

Use translation.get(options) to obtain this function for the specified Translation Collection and locale. The translator function is called with any parameters that you specify, and the translator function returns the appropriate translated string.

When you create a Translation Collection in the NetSuite UI, you can include parameter placeholders in your translation strings. Translation strings that include placeholders are called parametrized translation strings. Placeholders use braces and a number (starting from 1). The translator function injects the specified parameter values into the placeholders in the translation string.

For example, “Hello, {1}!” is a valid translation string, where {1} is a placeholder for a parameter. If you call translation.get(options) and specify a parameter of “NetSuite”, the translator function returns “Hello, NetSuite!” in the appropriate locale.

Supported Script Types

Client and server scripts

For additional information, see SuiteScript 2.x Script Types.

Module

N/translation Module

Sibling Object Members

N/translation Module Members

Since

2019.1

Parameters
Note:

The options parameter is a JavaScript object.

Parameter

Type

Required / Optional

Description

options.params

string[]

optional

The parameters to pass to the translator function.

The parameter values are used in parametrized translation strings.

Errors

Error Code

Thrown If

WRONG_PARAMETER_TYPE

The function parameters were not passed as an array.

Syntax

Important:

The following code sample shows the syntax for this member. It is not a functional example. For a complete script example, see N/translation Module Script Samples.

            // Add additional code
...
let 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
});
...
// Add additional code 

          

Related Topics

General Notices