Class: Compiler


new Compiler(mf)

Creates a new message compiler. Called internally from MessageFormat#compile.

Name Type Description
mf MessageFormat

A MessageFormat instance

Name Type Description
locales object

The locale identifiers that are used by the compiled functions

runtime object

Names of the core runtime functions that are used by the compiled functions

formatters object

The formatter functions that are used by the compiled functions



(static) bidiMarkText()

Utility formatter function for enforcing Bidi Structured Text by using UCC

List inlined from data extracted from CLDR v27 & v28 To verify/recreate, use the following:

git clone
cd cldr-misc-full/main/
grep characterOrder -r . | tr '"/' '\t' | cut -f2,6 | grep -C4 right-to-left

(static) funcname()

Utility function for escaping a function name if required


(static) propname()

Utility function for quoting an Object's key value if required

Quotes the key if it contains invalid characters or is an ECMAScript 3rd Edition reserved word (for IE8).


compile(src, lc, plurals)

Recursively compile a string or a tree of strings to JavaScript function sources

If src is an object with a key that is also present in plurals, the key in question will be used as the locale identifier for its value. To disable the compile-time checks for plural & selectordinal keys while maintaining multi-locale support, use falsy values in plurals.

Name Type Description
src string | object

the source for which the JS code should be generated

lc string

the default locale

plurals object

a map of pluralization keys for all available locales