translation.selectLocale(options)

Method Description

Creates a translation.Handle object in the specified locale from an existing translation.Handle object.

This method returns a translation.Handle object that contains the same translation strings as the options.handle object, and the strings are in the options.locale locale. Before you can use this method to select a locale, the locale must be loaded using the locales parameter of translation.load(options).

Returns

translation.Handle

Supported Script Types

Client and server scripts

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

Governance

None

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

translation.Handle

required

The translation.Handle object to select a locale for.

options.locale

string

required

The locale to select.

Use the values in the translation.Locale enum to set this value.

Errors

Error Code

Thrown If

SSS_MISSING_REQD_ARGUMENT

A handle or locale parameter is missing.

WRONG_PARAMETER_TYPE

The options.handle parameter is not a translation.Handle object.

INVALID_LOCALE

The specified translation.Handle object uses an unknown or unsupported locale.

TRANSLATION_HANDLE_IS_IN_AN_ILLEGAL_STATE

The specified translation.Handle object is in an illegal state.

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 germanStrings = translation.load({
    collections: [{
        alias: 'myCollection',
        collection: 'custcollection_my_strings',
        keys: ['MY_TITLE', 'MY_MESSAGE'],
    }],
    locales: [translation.Locale.de_DE, translation.Locale.es_ES]
});

let spanishStrings = translation.selectLocale({
    handle: germanStrings,
    locale: translation.Locale.es_ES
});
...
// Add additional code 

          

Related Topics

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

General Notices