as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

ProductNameFormat

Classdesc

ProductNameFormat provides methods to format a string with product name substitution. An argument pattern "$(pn)" is used as the placeholder for the product name in a format string resource.

Multiple product name types are available to use with format methods. Below is an example of Amazon Echo Show 5 product names in different types, | Type | Name | | :———– | :———————————- | | Generic | Device | | Short | Echo Show 5 | | Medium | Echo Show 5 (3rd Gen) | | Long | Echo Show 5 (3rd Generation) | | Full | Amazon Echo Show 5 (3rd Gen) | | Generational | Amazon Echo Show 5 (3rd Gen) |

A Default type is also available and maps to Medium type.

Example

import { ProductNameFormat, ProductNameType } from '@amazon-devices/keplerscript-kepleri18n-lib';
...
    // Pattern should be retrieved from string resources. It's hardcoded here for brevity of example only.
    const pattern: string = "This $(pn) is wifi enabled.";
    const message: string | null = ProductNameFormat.format(pattern, ProductNameType.MEDIUM);
    if (message === null) {
        // Error
        return;
    }
    // For the above Amazon Echo Show 5 product names example, message is "This Echo Show 5 (3rd Gen) is wifi enabled."

Constructors

new ProductNameFormat()

new ProductNameFormat(): ProductNameFormat

Returns

ProductNameFormat

Methods

format()

static format(pattern, productNameType, args?): null | string

Formats given pattern with product name substitution for the default locale. Optionally, the pattern may also be a MessageFormatClassic pattern with named arguments. The pattern is expected to contain one or more "$(pn)" substrings as placeholders for the product name.

In addition, this method supports "pngender" for product name gender message selection. To use it, just specify "pngender" in place of the IMessageFormatClassic select-format argument, and write select-format clauses based on the possible genders of other, feminine, masculine, neuter, female, male. For example,

Parameters

pattern

string

The pattern to format.

productNameType

ProductNameType = ProductNameType.DEFAULT

Type of product name to use.

args?

Map<string, string | number | Date>

Optional map of argument names to their values.

Returns

null | string

Formatted message with the specified product name replaced in place of "$(pn)" on success, null on failure.

Example

{pngender, select,
     *     feminine {$(pn) displays a notification on her screen.}
     *     masculine {$(pn) displays a notification on his screen.}
     *     other {$(pn) displays a notification on its screen.}}

If the current product gender is feminine and the product name is "Echo Show", this method will return
"Echo Show displays a notification on her screen."

Note

  • Do not use the name "pngender" as a named argument, as it is a reserved key by ProductNameFormat. If a "pngender" named argument is passed in the argument map, this method will fail.

formatPositional()

static formatPositional(pattern, productNameType, …args): null | string

Formats given pattern with product name substitution for the default locale. Optionally, the pattern may also be a MessageFormatClassic pattern with numbered arguments. The pattern is expected to contain one or more "$(pn)" substrings as placeholders for the product name.

See format() method regarding support for "pngender" product name gender message selection.

Parameters

pattern

string

The pattern to format.

productNameType

ProductNameType = ProductNameType.DEFAULT

Type of product name to use.

args

…(string | number | Date)[]

Optional array of argument values

Returns

null | string

Formatted message with the specified product name replaced in place of "$(pn)" on success, null on failure.


getMajorVersion()

static getMajorVersion(): number

Gets major version number.

Returns

number

Major version number.


getMinorVersion()

static getMinorVersion(): number

Gets minor version number.

Returns

number

Minor version number.


getPatchVersion()

static getPatchVersion(): number

Gets patch version number.

Returns

number

Patch version number.


Last updated: Sep 30, 2025