Class ListFmt
Create a new list formatter object that formats lists of items according to the options.
The options object can contain zero or more of the following parameters:
- locale locale to use to format this list, or undefined to use the default locale
- length - Specify the length of the format to use. The length is the approximate size of the
formatted string.
- short
- medium
- long
- full
- style the name of style to use to format the list, or undefined to use the default "standard" style. another style option is "units".
- onLoad - a callback function to call when the locale data is fully loaded and the address has been parsed. When the onLoad option is given, the address formatter object will attempt to load any missing locale data using the ilib loader callback. When the constructor is done (even if the data is already preassembled), the onLoad function is called with the current instance as a parameter, so this callback can be used with preassembled or dynamic loading or a mix of the two.
- sync - tell whether to load any missing locale data synchronously or asynchronously. If this option is given as "false", then the "onLoad" callback must be given, as the instance returned from this constructor will not be usable for a while.
- loadParams - an object containing parameters to pass to the loader callback function when locale data is missing. The parameters are not interpretted or modified in any way. They are simply passed along. The object may contain any property/value pairs as long as the calling code is in agreement with the loader callback function as to what those parameters mean.
Defined in: ListFmt.js.
Constructor Attributes | Constructor Name and Description |
---|---|
ListFmt(options)
|
Method Attributes | Method Name and Description |
---|---|
format(items)
Format a list of strings as grammatical text that is appropriate
for the locale of this formatter.
|
|
Return the locale of this formatter.
|
|
getStyle()
Return the style of names returned by this formatter
|
Class Detail
ListFmt(options)
- Parameters:
- {Object} options
- properties that control how this formatter behaves
Method Detail
{string}
format(items)
Format a list of strings as grammatical text that is appropriate
for the locale of this formatter.
- Parameters:
-
{Array.
} items - an array of strings to format in order that you would like them to appear
- Returns:
- {string} a string containing the list of items that is grammatically correct for the locale of this formatter
{string}
getLocale()
Return the locale of this formatter.
- Returns:
- {string} the locale of this formatter
{string}
getStyle()
Return the style of names returned by this formatter
- Returns:
- {string} the style of names returned by this formatter