ProductNameFormat API 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,
A Default type is also available and maps to Medium type.
Constructors
new ProductNameFormat()
new ProductNameFormat(): ProductNameFormat
Returns
ProductNameFormatMethods
format()
Formats the specified 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,staticformat(pattern:string, productNameType?: ProductNameType, args?:Map<string, string | number | Date> | undefined):string | null
Parameters
pattern
string
The pattern to format.
productNameType?
ProductNameType Type of product name to use.args?
Map<string, string | number | Date> | undefined
Optional map of argument names to their values.
Formatted message with the specified product name replaced in place of ”$(pn)” on success,
null on failure.
Returns
string | null
Examples
[!IMPORTANT] 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()
Formats the specified 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.staticformatPositional(pattern:string, productNameType?: ProductNameType, args?:(string | number | Date)[]):string | null
Parameters
pattern
string
The pattern to format.
productNameType?
ProductNameType Type of product name to use.args?
(string | number | Date)[]
Optional array of argument values
Formatted message with the specified product name replaced in place of ”$(pn)” on success,
null on failure.
Returns
string | null
getMajorVersion()
Gets the major version number. Major version number.staticgetMajorVersion():number
Returns
number
getMinorVersion()
Gets the minor version number. Minor version number.staticgetMinorVersion():number
Returns
number
getPatchVersion()
Gets the patch version number. Patch version number.staticgetPatchVersion():number
Returns
number

