labs.i18n.ListFormat Extends
ListFormat provides a method to format a list/array of objects to a string, in a user friendly way and in a locale sensitive manner. If the objects are not strings, toString is called to convert them. The constructor initializes the object based on the locale data from the current goog.labs.i18n.ListFormatSymbols. Similar to the ICU4J class com.ibm.icu.text.ListFormatter: http://icu-project.org/apiref/icu4j/com/ibm/icu/text/ListFormatter.html

Inheritance

Constructor

goog.labs.i18n.ListFormat()

Instance Methods

Public Protected Private
format(items) string
Formats an array of strings into a string. It is a user facing, locale-aware list (i.e. 'red, green, and blue').
Arguments:
items : !Array.<string | number>
Items to format.
Returns: string  The items formatted into a string, as a list.
code »
patternBasedJoinTwoStrings_(patternfirstsecond) string
Replaces the {0} and {1} placeholders in a pattern with the first and the second parameter respectively, and returns the result. It is a helper function for goog.labs.i18n.ListFormat.format.
Arguments:
pattern : string
used for formatting.
first : string
object to add to list.
second : string
object to add to list.
Returns: string  The formatted list string.
code »

Instance Properties

listEndPattern_ :
String for the end of a list items, containing {0} for the first part of the list, and {1} for the last item. This is how start/middle/end come together: start = '{0}, {1}' middle = '{0}, {1}', end = '{0}, and {1}' will result in the typical English list: 'one, two, three, and four' There are languages where the patterns are more complex than '{1} someText {1}' and the start pattern is different than the middle one.
Code »
listMiddlePattern_ :
String for the start of a list items, containing {0} for the first part of the list, and {1} for the rest of the list.
Code »
listStartPattern_ :
String for the start of a list items, containing {0} for the first, and {1} for the rest.
Code »
listTwoPattern_ :
String for lists of exactly two items, containing {0} for the first, and {1} for the second. For instance '{0} and {1}' will give 'black and white'.
Code »

Package labs.i18n

Package Reference