N/translation Module for SuiteScript Translations Management

The N/translation module enables SuiteScript developers to manage translation collections programmatically, enhancing localization efforts in NetSuite.

·3 min read·View Oracle Docs

The N/translation module allows SuiteScript developers to interact programmatically with NetSuite Translation Collections, which are crucial for effective localization. This module provides read-only access to translation data, enabling the retrieval of various translated strings intended for different language locales.

What is a Translation Collection?

A Translation Collection in NetSuite is a customization object that organizes translation strings alongside their respective translations. Each collection can contain multiple key/value pairs, where the key acts as an identifier and the value represents the original string that can be translated into multiple languages supported by NetSuite.

How Does the N/translation Module Work?

The N/translation module primarily relies on a hierarchical object known as translation.Handle. This object encapsulates a collection of translations for a specified locale. When you create a Translation Collection, you can incorporate parameter placeholders in your translation strings, allowing for dynamic content generation.

Utilizing the Translation Module

To access translation strings in your scripts, you exploit the following key methods and objects:

Key Methods and Objects

Member TypeNameReturn Type / Value TypeSupported Script TypeDescription
Objecttranslation.HandleObjectClient and server scriptsEncapsulates a Translation Collection for a locale.
Object / Functiontranslation.TranslatorObject / FunctionClient and server scriptsRepresents a translator function that returns translated strings with variables passed as parameters.
Methodtranslation.get(options)translation.TranslatorClient and server scriptsCreates a translator function for a key in the specified Translation Collection and locale.
Methodtranslation.load(options)translation.HandleClient and server scriptsCreates a translation.Handle object with translations for the specified Translation Collections and locales.
Methodtranslation.selectLocale(options)translation.HandleClient and server scriptsCreates a translation.Handle object in a specified locale from an existing translation.Handle object.
Enumtranslation.LocaleenumClient and server scriptsHolds supported locales for Translation Collections.

Code Sample

Here’s a sample code snippet demonstrating how to use the translation.get(options) method:

suitescript
1// key HELLO_1 = 'Hello, {1}'
2
3message: translation.get({
4 collection: 'custcollection_my_strings',
5 key: 'HELLO_1'
6})({
7 params: ['NetSuite']
8})

In this example, the function retrieves a translation string with a key of HELLO_1, which might return "Hello, NetSuite" when provided the corresponding parameter.

Managing Translation Collections in the UI

While the N/translation module provides programmatic access, managing Translation Collections also occurs within the NetSuite UI. Administrators can navigate to Customization > Translations > Manage Translations to create, edit, or delete collections depending on their needs.

Key Takeaways

  • The N/translation module provides SuiteScript developers with a way to manage translation collections programmatically.
  • Translation Collections store key/value pairs for easy localization across multiple languages supported by NetSuite.
  • Methods such as translation.get(options) and translation.load(options) enable retrieval and management of translation strings dynamically.
  • Administrators can manage collections directly through the NetSuite UI.

Source: This article is based on Oracle's official NetSuite documentation.

Frequently Asked Questions (4)

Can the N/translation module be used in both client and server scripts in NetSuite?
Yes, the N/translation module supports usage in both client and server scripts, making it versatile for different scripting scenarios in NetSuite.
How does the translation.Handle object function within the N/translation module?
The translation.Handle object encapsulates a collection of translations for a specified locale, allowing for easy access and management of translation strings in your scripts.
Is it possible to manage Translation Collections directly within the NetSuite UI?
Yes, administrators can manage Translation Collections through the NetSuite UI by navigating to Customization > Translations > Manage Translations, where they can create, edit, or delete collections.
Does the N/translation module allow for translation of dynamic content?
Yes, by incorporating parameter placeholders in translation strings, the N/translation module allows for the translation of dynamic content based on the parameters provided in the scripts.
Source: N/translation Module Members Oracle NetSuite Help Center. This article was generated from official Oracle documentation and enriched with additional context and best practices.

Was this article helpful?

More in Localization

View all Localization articles →