translation.get(options)

Note:

The content in this help topic pertains to SuiteScript 2.0.

Method Description

Creates a translator function for a key in the specified Translation Collection and locale.

This method returns a translator function, which is subsequently called with any specified parameters. When you call translation.get(options) and do not specify a locale, the method uses the current user's session locale. You can use the options.locale parameter to specify another locale. The translation.Locale enum lists all locales that are enabled for a company, and you can use these locales in translation.get(options).

Returns

translation.Translator

Supported Script Types

Client and server scripts

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

Governance

1 unit

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.collection

string

required

The script ID of the collection.

options.key

string

required

A valid key from the collection.

options.locale

string

optional

A valid locale from the translation.Locale enum.

If a locale is not specified, the locale from the current session is used as the default locale.

Errors

Error Code

Thrown If

SSS_MISSING_REQD_ARGUMENT

A collection or key parameter is missing.

INVALID_TRANSLATION_KEY

The format of a specified key is invalid.

INVALID_TRANSLATION_COLLECTION

The format of a specified collection is invalid.

INVALID_LOCALE

The format of a specified locale is invalid.

TRANSLATION_KEY_NOT_FOUND

A specified translation key was not found.

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

N/translation Module
SuiteScript 2.x Modules
SuiteScript 2.x

General Notices