diff --git a/docs/v3/MessageFormat.html b/docs/v3/MessageFormat.html new file mode 100644 index 00000000..d77ab74c --- /dev/null +++ b/docs/v3/MessageFormat.html @@ -0,0 +1,1768 @@ + + + + + + + messageformat Class: MessageFormat + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Class: MessageFormat

+
+ +
+ + +
+

MessageFormat-to-JavaScript compiler

+ + +
+ + +
+
+ + + +
+
+

new MessageFormat( [locale] [, options])

+ + +
+ +
+ + +
+

Create a new MessageFormat compiler

+
import MessageFormat from 'messageformat'
+
+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDescription
locale + + +string +| + +Array + + + + + + + <optional>
+ + + + + +

Define the locale or locales supported by this MessageFormat instance. If +given multiple valid locales, the first will be the default. If locale +is empty, it will fall back to MessageFormat.defaultLocale.

+

String locale values will be matched to plural categorisation functions +provided by the Unicode CLDR. If defining your own instead, use named +functions instead, optionally providing them with the properties: +cardinals: string[], ordinals: string[], module: string (to import +the formatter as a runtime dependency, rather than inlining its source).

+

If locale has the special value '*', it will match all available +locales. This may be useful if you want your messages to be completely +determined by your data, but may provide surprising results if your input +message object includes any 2-3 character keys that are not locale +identifiers.

options + + +MessageFormat~Options + + + + + + + <optional>
+ + + + + +

Compiler options

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + + + + + +

Members

+ +
+ +
+
+

<static> defaultLocale

+ + +
+
+ +
+

Used by the constructor when no locale argument is given.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
Default Value:
+
+
    +
  • 'en'
  • +
+
+ + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +

Methods

+ +
+ + +
+
+

<static> escape(str [, octothorpe])

+ + +
+ +
+ + +
+

Escape special characaters by surrounding the characters { and } in the +input string with 'quotes'. This will allow those characters to not be +considered as MessageFormat control characters.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
str + + +string + + + + + + + + + + + + +

The input string

octothorpe + + +boolean + + + + + + + <optional>
+ + + + + +
+ + false + +

Also escape #

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+

The escaped string

+
+ + + +
+
+ Type +
+
+ +string + + + +
+
+ + + + + +
+ + + + +
+
+

<static> supportedLocalesOf(locales)

+ + +
+ +
+ + +
+

Returns a subset of locales consisting of those for which MessageFormat +has built-in plural category support.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
locales + + +string +| + +Array.<string> + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +Array.<string> + + + +
+
+ + + + + +
+ + + + +
+
+

compile(message)

+ + +
+ +
+ + +
+

Compile a message into a function

+

Given a string message with ICU MessageFormat declarations, the result is +a function taking a single Object parameter representing each of the +input's defined variables, using the first valid locale.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
message + + +string + + + + +

The input message to be compiled, in ICU MessageFormat

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+
    +
  • The compiled function
  • +
+
+ + + +
+
+ Type +
+
+ +function + + + +
+
+ + + + + +
Example
+ +
const mf = new MessageFormat('en')
+const msg = mf.compile('A {TYPE} example.')
+
+msg({ TYPE: 'simple' })  // 'A simple example.'
+ + + +
+ + + + +
+
+

resolvedOptions()

+ + +
+ +
+ + +
+

Returns a new object with properties reflecting the default locale, +plurals, and other options computed during initialization.

+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + + + +
+
+ Type +
+
+ +MessageFormat~ResolvedOptions + + + +
+
+ + + + + +
+ +
+ + + +

Type Definitions

+ +
+ +
+
+

Options

+ + +
+
+ +
+

The shape of the options object +that may be used as the second argument of the constructor.

+
+ + + +
Type:
+
    +
  • + +Object + + + +
  • +
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeArgumentDefaultDescription
biDiSupport + + +boolean + + + + + + + <optional>
+ + + +
+ + false + +

Add Unicode control characters to +all input parts to preserve the integrity of the output when mixing LTR +and RTL text

currency + + +string + + + + + + + <optional>
+ + + +
+ + 'USD' + +

The currency to use when formatting +{V, number, currency}

customFormatters + + +Object + + + + + + + <optional>
+ + + +
+ +

Map of custom formatting functions +to include. See the Format Guide for more details.

requireAllArguments + + +boolean + + + + + + + <optional>
+ + + +
+ + false + +

Require all message +arguments to be set with a defined value

returnType + + +'string' +| + +'values' + + + + + + + <optional>
+ + + +
+ + 'string' + +

Return type of +compiled functions; either a concatenated string or an array (possibly +hierarchical) of values

strictNumberSign + + +boolean + + + + + + + <optional>
+ + + +
+ + false + +

Allow # only directly +within a plural or selectordinal case, rather than in any inner select +case as well.

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ + + +
+
+

ResolvedOptions

+ + +
+
+ + + +
Type:
+
    +
  • + +Object + + + +
  • +
+ + + +
+ + +
Properties:
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
biDiSupport + + +boolean + + + + +

Whether Unicode control characters be +added to all input parts to preserve the integrity of the output when +mixing LTR and RTL text

customFormatters + + +object + + + + +

Map of custom formatting functions

locale + + +string + + + + +

The default locale

plurals + + +Array.<object> + + + + +

All of the supported plurals

strictNumberSign + + +boolean + + + + +

Is # only allowed directly within +a plural or selectordinal case

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + +
+ +
+ + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/classes.list.html b/docs/v3/classes.list.html new file mode 100644 index 00000000..4e8476e3 --- /dev/null +++ b/docs/v3/classes.list.html @@ -0,0 +1,275 @@ + + + + + + + messageformat Classes + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Classes

+
+ +
+ + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +

Classes

+ +
+
MessageFormat
+
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/compile-module.js.html b/docs/v3/compile-module.js.html new file mode 100644 index 00000000..722b774d --- /dev/null +++ b/docs/v3/compile-module.js.html @@ -0,0 +1,287 @@ + + + + + + + messageformat Source: compile-module.js + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: compile-module.js

+ +
+
+
import { property } from 'safe-identifier';
+import Compiler from './compiler';
+
+function stringifyRuntime(runtime) {
+  const imports = {};
+  const vars = {};
+
+  for (const [name, fn] of Object.entries(runtime)) {
+    if (fn.module) {
+      const prev = imports[fn.module];
+      imports[fn.module] = prev ? [...prev, name] : [name];
+    } else {
+      vars[name] = String(fn);
+    }
+  }
+
+  const is = Object.entries(imports).map(
+    ([module, names]) =>
+      `import { ${names.sort().join(', ')} } from '${module}';`
+  );
+  const vs = Object.entries(vars).map(([id, value]) =>
+    new RegExp(`^function ${id}\\b`).test(value)
+      ? value
+      : `const ${id} = ${value};`
+  );
+
+  if (is.length > 0 && vs.length > 0) is.push('');
+  return is.concat(vs).join('\n');
+}
+
+function stringifyObject(obj, level = 0) {
+  if (typeof obj !== 'object') return obj;
+  const indent = '  '.repeat(level);
+  const o = Object.keys(obj).map(key => {
+    const v = stringifyObject(obj[key], level + 1);
+    return `\n${indent}  ${property(null, key)}: ${v}`;
+  });
+  return `{${o.join(',')}\n${indent}}`;
+}
+
+/**
+ * Compile a collection of messages into an ES module.
+ *
+ * ```
+ * import compileModule from 'messageformat/compile-module'
+ * ```
+ *
+ * With `messages` as a hierarchical structure of ICU MessageFormat strings,
+ * the output of `compileModule()` will be the source code of an ES module with
+ * a default export matching the input structure, with each string replaced by
+ * its corresponding JS function.
+ *
+ * If this MessageFormat instance has been initialized with support for more
+ * than one locale, using a key that matches the locale's identifier at any
+ * depth of a `messages` object will set its child elements to use that locale.
+ *
+ * @function compileModule
+ * @param {MessageFormat} messageformat - A MessageFormat instance
+ * @param {object} messages - The input messages to be compiled
+ * @returns {string} - String representation of the compiled module
+ *
+ * @example
+ * import fs from 'fs'
+ * import MessageFormat from 'messageformat'
+ * import compileModule from 'messageformat/compile-module'
+ *
+ * const mf = new MessageFormat('en')
+ * const msgSet = {
+ *   a: 'A {TYPE} example.',
+ *   b: 'This has {COUNT, plural, one{one member} other{# members}}.',
+ *   c: 'We have {P, number, percent} code coverage.'
+ * }
+ * const msgModule = compileModule(mf, msgSet)
+ * fs.writeFileSync('messages.js', msgModule)
+ *
+ * ...
+ *
+ * import messages from './messages'
+ *
+ * messages.a({ TYPE: 'more complex' })  // 'A more complex example.'
+ * messages.b({ COUNT: 3 })              // 'This has 3 members.'
+ */
+export default function compileModule(messageformat, messages) {
+  const { plurals } = messageformat;
+  const cp = {};
+  if (plurals.length > 1)
+    for (const pl of plurals) cp[pl.lc] = cp[pl.locale] = pl;
+  const compiler = new Compiler(messageformat.options);
+  const msgObj = compiler.compile(messages, plurals[0], cp);
+  const msgStr = stringifyObject(msgObj);
+  const rtStr = stringifyRuntime(compiler.runtime);
+  return `${rtStr}\nexport default ${msgStr}`;
+}
+
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/v3/fonts/glyphicons-halflings-regular.eot b/docs/v3/fonts/glyphicons-halflings-regular.eot new file mode 100644 index 00000000..b93a4953 Binary files /dev/null and b/docs/v3/fonts/glyphicons-halflings-regular.eot differ diff --git a/docs/v3/fonts/glyphicons-halflings-regular.svg b/docs/v3/fonts/glyphicons-halflings-regular.svg new file mode 100644 index 00000000..94fb5490 --- /dev/null +++ b/docs/v3/fonts/glyphicons-halflings-regular.svg @@ -0,0 +1,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/fonts/glyphicons-halflings-regular.ttf b/docs/v3/fonts/glyphicons-halflings-regular.ttf new file mode 100644 index 00000000..1413fc60 Binary files /dev/null and b/docs/v3/fonts/glyphicons-halflings-regular.ttf differ diff --git a/docs/v3/fonts/glyphicons-halflings-regular.woff b/docs/v3/fonts/glyphicons-halflings-regular.woff new file mode 100644 index 00000000..9e612858 Binary files /dev/null and b/docs/v3/fonts/glyphicons-halflings-regular.woff differ diff --git a/docs/v3/fonts/glyphicons-halflings-regular.woff2 b/docs/v3/fonts/glyphicons-halflings-regular.woff2 new file mode 100644 index 00000000..64539b54 Binary files /dev/null and b/docs/v3/fonts/glyphicons-halflings-regular.woff2 differ diff --git a/docs/v3/global.html b/docs/v3/global.html new file mode 100644 index 00000000..00dcdae4 --- /dev/null +++ b/docs/v3/global.html @@ -0,0 +1,494 @@ + + + + + + + messageformat Global + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Global

+
+ +
+ + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + +

Methods

+ +
+ + +
+
+

compileModule(messageformat, messages)

+ + +
+ +
+ + +
+

Compile a collection of messages into an ES module.

+
import compileModule from 'messageformat/compile-module'
+
+

With messages as a hierarchical structure of ICU MessageFormat strings, +the output of compileModule() will be the source code of an ES module with +a default export matching the input structure, with each string replaced by +its corresponding JS function.

+

If this MessageFormat instance has been initialized with support for more +than one locale, using a key that matches the locale's identifier at any +depth of a messages object will set its child elements to use that locale.

+
+ + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
messageformat + + +MessageFormat + + + + +

A MessageFormat instance

messages + + +object + + + + +

The input messages to be compiled

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ +
+ + + + + + + +
+ + + + + + + + + + + + + +
Returns:
+ + +
+
    +
  • String representation of the compiled module
  • +
+
+ + + +
+
+ Type +
+
+ +string + + + +
+
+ + + + + +
Example
+ +
import fs from 'fs'
+import MessageFormat from 'messageformat'
+import compileModule from 'messageformat/compile-module'
+
+const mf = new MessageFormat('en')
+const msgSet = {
+  a: 'A {TYPE} example.',
+  b: 'This has {COUNT, plural, one{one member} other{# members}}.',
+  c: 'We have {P, number, percent} code coverage.'
+}
+const msgModule = compileModule(mf, msgSet)
+fs.writeFileSync('messages.js', msgModule)
+
+...
+
+import messages from './messages'
+
+messages.a({ TYPE: 'more complex' })  // 'A more complex example.'
+messages.b({ COUNT: 3 })              // 'This has 3 members.'
+ + + +
+ +
+ + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/img/glyphicons-halflings-white.png b/docs/v3/img/glyphicons-halflings-white.png new file mode 100644 index 00000000..3bf6484a Binary files /dev/null and b/docs/v3/img/glyphicons-halflings-white.png differ diff --git a/docs/v3/img/glyphicons-halflings.png b/docs/v3/img/glyphicons-halflings.png new file mode 100644 index 00000000..a9969993 Binary files /dev/null and b/docs/v3/img/glyphicons-halflings.png differ diff --git a/docs/v3/index.html b/docs/v3/index.html new file mode 100644 index 00000000..a5ae2b9c --- /dev/null +++ b/docs/v3/index.html @@ -0,0 +1,258 @@ + + + + + + + messageformat Index + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ + + + + + + + + + + + + + +
+
+ +Build Status +

messageformat

+
+

The experience and subtlety of your program's text can be important. Messageformat is a mechanism for handling both pluralization and gender in your applications. It can also lead to much better translations, as it's designed to support all the languages included in the Unicode CLDR.

+

The ICU has an official guide for the format. Messageformat supports and extends all parts of the standard, with the exception of the deprecated ChoiceFormat.

+

There is a good slide-deck on Plural and Gender in Translated Messages by Markus Scherer and Mark Davis. But, again, remember that many of these problems apply even if you're only outputting english.

+

What problems does it solve?

+

Using messageformat, you can separate your code from your text formatting, while enabling much more humane expressions. In other words, you won't need to see this anymore in your output:

+
+

There are 1 results.
+There are 2 result(s).
+Number of results: 3.

+
+

On a more fundamental level, messageformat and its associated tools can help you build an effective workflow for UI texts and translations, keeping message sources in human-friendly formats, compiling them into JavaScript during your build phase, and making them easy to use from your application code.

+

What does it look like?

+

With this message:

+
const msgSrc = `{GENDER, select,
+  male {He}
+  female {She}
+  other {They}
+} found {RES, plural,
+  =0 {no results}
+  one {1 result}
+  other {# results}
+}.`;
+
+

You'll get these results:

+
const MessageFormat = require('messageformat');
+const mf = new MessageFormat('en');
+const msg = mf.compile(msgSrc);
+
+msg({ GENDER: 'male', RES: 1 }); // 'He found 1 result.'
+msg({ GENDER: 'female', RES: 1 }); // 'She found 1 result.'
+msg({ GENDER: 'male', RES: 0 }); // 'He found no results.'
+msg({ RES: 2 }); // 'They found 2 results.'
+
+

Getting Started

+
npm install --save-dev messageformat@next
+npm install --save messageformat-runtime
+
+

This includes the MessageFormat compiler and a runtime accessor class that provides a slightly nicer API for working with larger numbers of messages. Our Format Guide will help with the ICU MessageFormat Syntax, and the Usage Guide provides some options for integrating messageformat to be a part of your workflow around UI texts and translations.

+
+

Messageformat is an OpenJS Foundation project, and we follow its Code of Conduct.

+ +OpenJS Foundation + +

Browser testing provided by:

+ +BrowserStack +
+
+ + + + + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/logo/browserstack.svg b/docs/v3/logo/browserstack.svg new file mode 100644 index 00000000..195f64d2 --- /dev/null +++ b/docs/v3/logo/browserstack.svg @@ -0,0 +1,90 @@ + + + + +Browserstack-logo-white + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/v3/logo/favicon-180.png b/docs/v3/logo/favicon-180.png new file mode 100644 index 00000000..291cdcf1 Binary files /dev/null and b/docs/v3/logo/favicon-180.png differ diff --git a/docs/v3/logo/favicon-32.png b/docs/v3/logo/favicon-32.png new file mode 100644 index 00000000..123bbaaa Binary files /dev/null and b/docs/v3/logo/favicon-32.png differ diff --git a/docs/v3/logo/messageformat-with-text.svg b/docs/v3/logo/messageformat-with-text.svg new file mode 100644 index 00000000..b2a6cd2d --- /dev/null +++ b/docs/v3/logo/messageformat-with-text.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/v3/logo/messageformat.svg b/docs/v3/logo/messageformat.svg new file mode 100644 index 00000000..e069ba67 --- /dev/null +++ b/docs/v3/logo/messageformat.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/docs/v3/logo/openjsf.svg b/docs/v3/logo/openjsf.svg new file mode 100644 index 00000000..fa063e7c --- /dev/null +++ b/docs/v3/logo/openjsf.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/v3/messageformat.js.html b/docs/v3/messageformat.js.html new file mode 100644 index 00000000..3b9ab611 --- /dev/null +++ b/docs/v3/messageformat.js.html @@ -0,0 +1,365 @@ + + + + + + + messageformat Source: messageformat.js + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Source: messageformat.js

+ +
+
+
import Compiler from './compiler';
+import { getAllPlurals, getPlural, hasPlural } from './plurals';
+
+export default class MessageFormat {
+  /**
+   * Used by the constructor when no `locale` argument is given.
+   *
+   * @memberof MessageFormat
+   * @default 'en'
+   */
+  static defaultLocale = 'en';
+
+  /**
+   * Escape special characaters by surrounding the characters `{` and `}` in the
+   * input string with 'quotes'. This will allow those characters to not be
+   * considered as MessageFormat control characters.
+   *
+   * @memberof MessageFormat
+   * @param {string} str - The input string
+   * @param {boolean} [octothorpe=false] - Also escape `#`
+   * @returns {string} The escaped string
+   */
+  static escape(str, octothorpe) {
+    const esc = octothorpe ? /[#{}]/g : /[{}]/g;
+    return String(str).replace(esc, "'$&'");
+  }
+
+  /**
+   * Returns a subset of `locales` consisting of those for which MessageFormat
+   * has built-in plural category support.
+   *
+   * @memberof MessageFormat
+   * @param {(string|string[])} locales
+   * @returns {string[]}
+   */
+  static supportedLocalesOf(locales) {
+    const la = Array.isArray(locales) ? locales : [locales];
+    return la.filter(hasPlural);
+  }
+
+  /**
+   * @typedef {Object} MessageFormat~Options - The shape of the options object
+   *   that may be used as the second argument of the constructor.
+   * @property {boolean} [biDiSupport=false] - Add Unicode control characters to
+   *   all input parts to preserve the integrity of the output when mixing LTR
+   *   and RTL text
+   * @property {string} [currency='USD'] - The currency to use when formatting
+   *   `{V, number, currency}`
+   * @property {Object} [customFormatters] - Map of custom formatting functions
+   *   to include. See the {@page guide} for more details.
+   * @property {boolean} [requireAllArguments=false] - Require all message
+   *   arguments to be set with a defined value
+   * @property {('string'|'values')} [returnType='string'] - Return type of
+   *   compiled functions; either a concatenated string or an array (possibly
+   *   hierarchical) of values
+   * @property {boolean} [strictNumberSign=false] - Allow `#` only directly
+   *   within a plural or selectordinal case, rather than in any inner select
+   *   case as well.
+   */
+
+  /**
+   * Create a new MessageFormat compiler
+   *
+   * ```
+   * import MessageFormat from 'messageformat'
+   * ```
+   *
+   * @class MessageFormat
+   * @classdesc MessageFormat-to-JavaScript compiler
+   * @param {string|Array} [locale]
+   *   Define the locale or locales supported by this MessageFormat instance. If
+   *   given multiple valid locales, the first will be the default. If `locale`
+   *   is empty, it will fall back to `MessageFormat.defaultLocale`.
+   *
+   *   String `locale` values will be matched to plural categorisation functions
+   *   provided by the Unicode CLDR. If defining your own instead, use named
+   *   functions instead, optionally providing them with the properties:
+   *   `cardinals: string[]`, `ordinals: string[]`, `module: string` (to import
+   *   the formatter as a runtime dependency, rather than inlining its source).
+   *
+   *   If `locale` has the special value `'*'`, it will match *all* available
+   *   locales. This may be useful if you want your messages to be completely
+   *   determined by your data, but may provide surprising results if your input
+   *   message object includes any 2-3 character keys that are not locale
+   *   identifiers.
+   * @param {MessageFormat~Options} [options] - Compiler options
+   */
+  constructor(locale, options) {
+    this.options = Object.assign(
+      {
+        biDiSupport: false,
+        currency: 'USD',
+        customFormatters: {},
+        returnType: 'string',
+        strictNumberSign: false
+      },
+      options
+    );
+    if (locale === '*') {
+      this.plurals = getAllPlurals(MessageFormat.defaultLocale);
+    } else if (Array.isArray(locale)) {
+      this.plurals = locale.map(getPlural).filter(Boolean);
+    } else if (locale) {
+      const pl = getPlural(locale);
+      if (pl) this.plurals = [pl];
+    }
+    if (!this.plurals || this.plurals.length === 0) {
+      const pl = getPlural(MessageFormat.defaultLocale);
+      this.plurals = [pl];
+    }
+  }
+
+  /**
+   * @typedef {Object} MessageFormat~ResolvedOptions
+   * @property {boolean} biDiSupport - Whether Unicode control characters be
+   *   added to all input parts to preserve the integrity of the output when
+   *   mixing LTR and RTL text
+   * @property {object} customFormatters - Map of custom formatting functions
+   * @property {string} locale - The default locale
+   * @property {object[]} plurals - All of the supported plurals
+   * @property {boolean} strictNumberSign - Is `#` only allowed directly within
+   *   a plural or selectordinal case
+   */
+
+  /**
+   * Returns a new object with properties reflecting the default locale,
+   * plurals, and other options computed during initialization.
+   *
+   * @memberof MessageFormat
+   * @instance
+   * @returns {MessageFormat~ResolvedOptions}
+   */
+  resolvedOptions() {
+    return {
+      ...this.options,
+      locale: this.plurals[0].locale,
+      plurals: this.plurals
+    };
+  }
+
+  /**
+   * Compile a message into a function
+   *
+   * Given a string `message` with ICU MessageFormat declarations, the result is
+   * a function taking a single Object parameter representing each of the
+   * input's defined variables, using the first valid locale.
+   *
+   * @memberof MessageFormat
+   * @instance
+   * @param {string} message - The input message to be compiled, in ICU MessageFormat
+   * @returns {function} - The compiled function
+   *
+   * @example
+   * const mf = new MessageFormat('en')
+   * const msg = mf.compile('A {TYPE} example.')
+   *
+   * msg({ TYPE: 'simple' })  // 'A simple example.'
+   */
+  compile(message) {
+    const compiler = new Compiler(this.options);
+    const fnBody = 'return ' + compiler.compile(message, this.plurals[0]);
+    const nfArgs = [];
+    const fnArgs = [];
+    for (const [key, fmt] of Object.entries(compiler.runtime)) {
+      nfArgs.push(key);
+      fnArgs.push(fmt);
+    }
+    const fn = new Function(...nfArgs, fnBody);
+    return fn.apply(null, fnArgs);
+  }
+}
+
+
+
+ + + + + +
+
+ +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + diff --git a/docs/v3/page-about.html b/docs/v3/page-about.html new file mode 100644 index 00000000..40fad14c --- /dev/null +++ b/docs/v3/page-about.html @@ -0,0 +1,249 @@ + + + + + + + messageformat: About + + + + + + + + + + + + + + + +
+
+ + +
+ +
+
+ +
+ + +

About

+
+ +
+

Messageformat is an OpenJS Foundation project, and we follow its Code of Conduct.

+

Features

+
    +
  • Handles arbitrary nesting of pluralization and select rules
  • +
  • Supports all ~466 languages included in the Unicode CLDR
  • +
  • Works on the server and the client
  • +
  • Remarkably useful even for single-language use
  • +
  • Speed & efficiency: Can pre-compile messages to JavaScript code +
      +
    • Great for speed: message formatting is just string concatenation
    • +
    +
  • +
  • Compatible with other MessageFormat implementations
  • +
  • Extendable with custom formatting functions
  • +
  • Very whitespace tolerant
  • +
  • Supports Unicode, including RTL and mixed LTR/RTL strings
  • +
+

License

+

You may use this software under the MIT License:

+
+

Copyright OpenJS Foundation and contributors, https://openjsf.org/

+

Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions:

+

The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software.

+

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

+
+

Contributor License Agreement

+

We require all code contributions to be covered under the OpenJS Foundation's Contributor License Agreement. This can be done electronically and essentially ensures that you are making it clear that your contributions are your contributions and that you have the legal right to contribute them under our MIT license. If you've not previously signed the CLA, our bot will provide you with instructions for how to do so.

+

Core Contributors

+ +

Credits

+

Thanks to:

+
    +
  • Vincit - Eemeli's current employer - for letting him do cool stuff like this.
  • +
  • Bazaarvoice - Alex's previous employer - for letting him do cool stuff like this.
  • +
  • Google has an implementation that is similar in Google Closure, the code has been vetted against many of their tests.
  • +
  • Norbert Lindenberg for showing Alex how good it can be.
  • +
+
+ +
+ +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/page-build.html b/docs/v3/page-build.html new file mode 100644 index 00000000..9f030d84 --- /dev/null +++ b/docs/v3/page-build.html @@ -0,0 +1,302 @@ + + + + + + + messageformat: Usage + + + + + + + + + + + + + + + +
+
+ + +
+ +
+
+ +
+ + +

Usage

+
+ +
+

Fundamentally, messageformat is a compiler that turns ICU MessageFormat input into JavaScript. While it's certainly possible to use it directly in your client code, that will mean including the full compiler in your client-side code (admittedly, just 15kB when minified & gzipped), and being okay with new Function being called for each message string.

+

The recommended alternative is to use messageformat as a compile-time tool. To that end, we provide three different sorts of solutions:

+
    +
  • Webpack loaders for JSON, .properties, gettext PO, and YAML files
  • +
  • messageformat-cli for command-line use, supporting JSON and .properties files
  • +
  • Our JavaScript API, in particular MessageFormat#compile
  • +
+

Compiling messages during your build will allow for a significant decrease in filesize and execution time, as all that's required to run on the client are the final compiled functions.

+

Webpack loaders

+

Each of the loaders is similar, supporting a specific file type. Their configuration options vary slightly, depending on the common practices for the format; please see their own documentations for details:

+ +

Using messageformat-loader as an example, these enable a JavaScript API that looks like this:

+
+
messages.json
+
+
{
+  "time": "{0} took {1} ms to complete.",
+  "ordinal": "The {N, selectordinal, one{#st} two{#nd} few{#rd} other{#th}} message."
+}
+
+
+
+
example.js
+
+
import messages from './messages.json'
+messages.ordinal(['Sweeping', 42])  // 'Sweeping took 42 ms to complete.'
+messages.ordinal({ N: 1 })          // 'The 1st message.'
+
+
+

During the build, the loader will compile your messages into their respective functions, and package only those into the webpack output.

+

CLI Compiler

+

messageformat-cli is available as a separate package, and is easy to integrate into any build environment that can execute external commands, such as create-react-app. In addition to command-line options, the CLI can read configuration from package.json and messageformat.rc.json files; see its documentation for more information.

+
$ npm install messageformat messageformat-cli
+$ npx messageformat
+
+usage: messageformat [options] [input, ...]
+
+Parses the input JSON and .properties files of MessageFormat strings into
+a JS module of corresponding hierarchical functions. Input directories are
+recursively scanned for all .json and .properties files.
+
+  -l lc, --locale=lc
+        The locale(s) lc to include; if multiple, selected by matching
+        message key. If not set, path keys matching any locale code will set
+        the active locale, starting with a default 'en' locale.
+
+  -n ns, --namespace=ns
+        By default, output is an ES6 module with a default export; set ns
+        to support other environments. If ns does not contain a '.', the
+        output follows an UMD pattern. For CommonJS module output, use
+        --namespace=module.exports.
+
+  -o of, --outfile=of
+        Write output to the file of. If undefined or '-', prints to stdout
+
+See the messageformat-cli README for more options. Configuration may also be
+set in package.json or messageformat.rc.json.
+
+

Using compiled messageformat output

+

The output of the loaders and the CLI will be a hierarchical object, made up of the non-identical file and object paths of the input. For example, the messageformat package's example/i18n.js sample output includes a function en.sub.folder.plural.test(), which was compiled from the test key in the source file example/en/sub/folder/plural.json. Obviously this is a slightly contribed example, but even in real-world use it's likely that you'll end up with a sufficient number of messages that it makes sense to split them in separate files and/or into some sort of hierarchy.

+

In development use, it may then prove problematic to use the messageformat compiled messages directly, as mistakes in message keys will throw errors when they are called as functions, along with errors from missing properties for messages using variables. To that end, the library includes Messages, a utility accessor library that helps with common usage patterns, as well as making it easier to load message data dynamically.

+

It works like this (using messageformat-loader, configured for en and fi locales):

+
+
messages.json
+
+
{
+  "en": {
+    "a": "A {TYPE} example.",
+    "b": "This has {COUNT, plural, one{one user} other{# users}}.",
+    "c": {
+      "d": "We have {P, number, percent} code coverage."
+    }
+  },
+  "fi": {
+    "b": "Tällä on {COUNT, plural, one{yksi käyttäjä} other{# käyttäjää}}.",
+    "e": "Minä puhun vain suomea."
+  }
+}
+
+
+
+
example.js
+
+
import Messages from 'messageformat-runtime/messages'
+import msgData from './messages.json'
+const messages = new Messages(msgData, 'en')  // sets default locale
+

messages.hasMessage('a') // true +messages.hasObject('c') // true +messages.get('b', { COUNT: 3 }) // 'This has 3 users.' +messages.get(['c', 'd'], { P: 0.314 }) // 'We have 31% code coverage.'

+

messages.get('e') // 'e' +messages.setFallback('en', ['foo', 'fi']) +messages.get('e') // 'Minä puhun vain suomea.'

+

messages.locale = 'fi' +messages.hasMessage('a') // false +messages.hasMessage('a', 'en') // true +messages.hasMessage('a', null, true) // true +messages.hasObject('c') // false +messages.get('b', { COUNT: 3 }) // 'Tällä on 3 käyttäjää.' +messages.get('c').d({ P: 0.628 }) // 'We have 63% code coverage.'

+
+
+
+ +
+ +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/page-guide.html b/docs/v3/page-guide.html new file mode 100644 index 00000000..a3471e1d --- /dev/null +++ b/docs/v3/page-guide.html @@ -0,0 +1,446 @@ + + + + + + + messageformat: Format Guide + + + + + + + + + + + + + + + +
+
+ + +
+ +
+
+ +
+ + +

Format Guide

+
+ +
+

This guide aims to provide an introduction to ICU MessageFormat syntax, along +with minimal code examples that are directly executable in a node.js +environment. For production use, we recommend using Usage and +the Messages runtime accessor class.

+

String Lookup

+

The simplest case of MessageFormat involves no formatting, just a string +passthrough. This may sound silly, but often it's nice to always use the same +message formatting system when doing translations, and not everything requires +variables.

+
const MessageFormat = require('messageformat');
+const mf = new MessageFormat('en');
+const message = mf.compile('This is a message.');
+
+message(); // "This is a message."
+
+

Note: if a message does require data to be passed in, an error is thrown if +you do not.

+

Variables

+

The most common way to use MessageFormat is for simple variable replacement. +MessageFormat may look odd at first, but it's actually fairly simple. One way to +think about the { and } is that every level of them bring you into and +out-of "literal" and "code" mode.

+

By default (like in the previous example), you are just writing a literal. Then +the first level of brackets brings you into one of several data-driven +situations. The most simple is variable replacement.

+

Simply putting a variable name in between { and } will place that variable +there in the output.

+
const MessageFormat = require('messageformat');
+const mf = new MessageFormat('en');
+const varMessage = mf.compile('His name is {NAME}.');
+
+varMessage({ NAME: 'Jed' }); // 'His name is Jed.'
+
+

SelectFormat

+

SelectFormat is a lot like a switch statement for your messages. Often it's used +to select gender in a string. The format of the statement is {varname, select, this{...} that{...} other{...}}, where varname matches a key in the data you +give to the resulting function, and 'this' and 'that' are some of the +string-equivalent values that it may have. The other key is required, and is +selected if no other case matches.

+

Note: Comparison is made using the JavaScript == operator, so if a key is +left out of the input data, the case undefined{...} would match that.

+
const MessageFormat = require('messageformat');
+const mf = new MesssageFormat('en');
+const selectMessage = mf.compile(
+  `{ GENDER, select,
+       male {He}
+       female {She}
+       other {They}
+   } liked this.`
+);
+
+selectMessage({ GENDER: 'male' }); // 'He liked this.'
+selectMessage({ GENDER: 'female' }); // 'She liked this.'
+selectMessage({}); // 'They liked this.'
+
+

PluralFormat

+

PluralFormat is a similar mechanism to SelectFormat, but specific to numerical +values. The key that is chosen is generated from the specified input variable by +a locale-specific plural function.

+

The numeric input is mapped to a plural category, some subset of zero, one, +two, few, many, and other depending on the locale and the type of plural. +English, for instance, uses one and other for cardinal plurals (e.g. "one +result", "many results") and one, two, few, and other for ordinal +plurals (e.g. "1st result", "2nd result", etc). For information on which keys +are used by your locale, please refer to the CLDR table of plural rules.

+

For some languages, The number of printed digits is significant (e.g. "1 meter", +"1.0 meters"); to account for that you may pass in the value as a stringified +representation of the number.

+

Matches for exact values are available with the = prefix, e.g. =0 and =1.

+

The keyword for cardinal plurals is plural, and for ordinal plurals is +selectordinal.

+

Within a plural statement, # will be replaced by the variable value.

+
const MessageFormat = require('messageformat');
+const mf = new MessageFormat('en');
+const messages = mf.compile({
+  results: `There { COUNT, plural,
+                    =0 {are no results}
+                    one {is one result}
+                    other {are # results}
+                  }.`,
+  position: `You are { POS, selectordinal,
+                       one {#st}
+                       two {#nd}
+                       few {#rd}
+                       other {#th}
+                     } in the queue.`
+});
+
+messages.results({ COUNT: 0 }); // 'There are no results.'
+messages.results({ COUNT: 1 }); // 'There is one result.'
+messages.results({ COUNT: 100 }); // 'There are 100 results.'
+messages.position({ POS: 1 }); // 'You are 1st in the queue.'
+messages.position({ POS: 33 }); // 'You are 33rd in the queue.'
+
+

Plural Offset

+

To generate sentences such as "You and 4 others added this to their profiles.", +PluralFormat supports subtracting an offset from the variable value before +determining its plural category. Literal/exact matches are tested before +applying the offset.

+
const MessageFormat = require('messageformat');
+const mf = new MessageFormat('en');
+const offsetMessage = mf.compile(
+  `You { ADDS, plural, offset:1
+         =0 {did not add this}
+         =1 {added this}
+         one {and one other person added this}
+         other {and # others added this}
+       }.`
+);
+
+offsetMessage({ ADDS: 0 }); // 'You did not add this.'
+offsetMessage({ ADDS: 1 }); // 'You added this.'
+offsetMessage({ ADDS: 2 }); // 'You and one other person added this.'
+offsetMessage({ ADDS: 3 }); // 'You and 2 others added this.'
+
+

Formatters

+

MessageFormat includes date, duration, number, and time formatting functions in +the style of ICU's simpleArg syntax. They are implemented using the Intl +object defined by ECMA-402.

+

Note: Intl is not defined in Node by default until 0.12 and is not available +in all browsers (in particular, IE <=10 and Safari <=9.1), so you may need to +use a polyfill. Also, even relatively recent versions of browsers may have +incomplete or non-standard support for all advanced features used by the date +and number formatter skeletons.

+

date and time

+

For simple cases, both date and time support the parameters short, default, long , and full. For more precide date and time formatting, use date with a ::-prefixed DateFormat skeleton string like {T, date, ::hamszzzz}

+
const MessageFormat = require('messageformat');
+const mf = new MessageFormat(['en', 'fi']);
+const messages = mf.compile({
+  en: {
+    eagle: 'The Eagle landed at {T, time, full} on {T, date, full}',
+    now: 'The time is now {T, time}',
+    today: 'Today is {T, date}',
+    unix: 'Unix time started on {T, date, full}',
+    uptime: '{sys} became operational on {d0, date, short}'
+  },
+  fi: {
+    now: 'Kello on nyt {T, time}',
+    today: 'Tänään on {T, date}'
+  }
+});
+
+messages.en.now({ T: Date.now() }); // 'The time is now 11:26:35 PM'
+messages.fi.now({ T: Date.now() }); // 'Kello on nyt 23.26.35'
+
+messages.en.today({ T: Date.now() }); // 'Today is Mar 30, 2018'
+messages.fi.today({ T: Date.now() }); // 'Tänään on 30. maalisk. 2018'
+messages.en.unix({ T: 0 });
+// 'Unix time started on Thursday, January 1, 1970'
+messages.en.uptime({ sys: 'HAL 9000', d0: '12 January 1999' });
+// 'HAL 9000 became operational on 1/12/1999'
+
+messages.en.eagle({ T: '1969-07-20 20:17:40 UTC' });
+// 'The Eagle landed at 10:17:40 PM GMT+2 on Sunday, July 20, 1969'
+
+

duration

+

Represent a duration in seconds as a string.

+
const MessageFormat = require('messageformat');
+const mf = new MessageFormat();
+const messages = mf.compile({
+  since: 'It has been {D, duration}',
+  countdown: 'Countdown: {D, duration}'
+});
+
+messages.since({ D: 123 }); // 'It has been 2:03'
+messages.countdown({ D: -151200.42 }); // 'Countdown: -42:00:00.420'
+
+

number

+

Supported simple parameters are integer, percent , or currency. For more options, use a NumberFormat skeleton string. Most NumberFormat patterns are also supported.

+
const MessageFormat = require('messageformat');
+const mf = new MessageFormat('en');
+mf.currency = 'EUR'; // needs to be set before first compile() call
+const messages = mf.compile({
+  almost: '{N} is almost {N, number, integer}',
+  complete: '{P, number, percent} complete',
+  currency: {
+    eur: 'The total is {V, number, currency}.',
+    gbp: 'The total is {V, number, ::currency/GBP unit-width-narrow}.'
+  }
+});
+
+messages.almost({ N: 3.14 }); // '3.14 is almost 3'
+messages.complete({ P: 0.99 }); // '99% complete'
+messages.currency.eur({ V: 5.5 }); // 'The total is €5.50.'
+messages.currency.gbp({ V: 5.5 }); // 'The total is £5.50.'
+
+

Custom Formatters

+

In MessageFormat source, a formatter function is called with the syntax +{var, name, arg}, where var is a variable, name is the formatter name +(by default, either date, duration, number or time; spellout and +ordinal are not supported by default), and arg is an optional string +argument.

+

In JavaScript, a formatter is a function called with three parameters:

+
    +
  • The value of the variable; this can be of any user-defined type
  • +
  • The current locale code
  • +
  • The trimmed arg string value, or null if not set
  • +
+

As formatter functions may be used in a precompiled context, they should not +refer to any variables that are not defined by the function parameters or +within the function body. To add your own formatter, use the customFormatters +option of the MessageFormat constructor.

+
const MessageFormat = require('messageformat');
+const customFormatters = {
+  upcase: function (v) {
+    return v.toUpperCase();
+  },
+  locale: function (v, lc) {
+    return lc;
+  },
+  prop: function (v, lc, p) {
+    return v[p];
+  }
+};
+const mf = new MessageFormat('en-GB', { customFormatters });
+const messages = mf.compile({
+  describe: 'This is {VAR, upcase}.',
+  locale: 'The current locale is {_, locale}.',
+  answer: 'Answer: {obj, prop, a}'
+});
+
+messages.describe({ VAR: 'big' }); // 'This is BIG.'
+messages.locale({}); // 'The current locale is en-GB.'
+messages.answer({ obj: { q: 3, a: 42 } }); // 'Answer: 42'
+
+

Nesting

+

All types of messageformat statements may be nested within each other, to unlimited depth:

+
{ SEL1, select,
+  other {
+    { PLUR1, plural,
+      one {1}
+      other {
+        { SEL2, select, other {Deep in the heart.} }
+      }
+    }
+  }
+}
+
+

Escaping

+

The characters { and } must be escaped with 'quotes' to be included in the output as literal characters. Within plural statements, # must also be similarly escaped. The utility function MessageFormat.escape may help with this.

+
const MessageFormat = require('messageformat');
+const mf = new MessageFormat('en');
+const messages = mf.compile({
+  esc: "'{' {S, plural, other{# is a '#'}} '}'",
+  var: MessageFormat.escape('Use {var} for variables')
+});
+
+messages.esc({ S: 5 }); // '{ 5 is a # }'
+messages.var({ var: 5 }); // 'Use {var} for variables'
+
+
+ +
+ +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/pages.list.html b/docs/v3/pages.list.html new file mode 100644 index 00000000..9e399d9f --- /dev/null +++ b/docs/v3/pages.list.html @@ -0,0 +1,275 @@ + + + + + + + messageformat Tutorials + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ + +

Tutorials

+
+ +
+ + + +
+ + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +

Classes

+ +
+
MessageFormat
+
+
+ + + + + + + + + + + + + +
+ +
+ + + + +
+
+ +
+ + +
+ +
+ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/v3/scripts/docstrap.lib.js b/docs/v3/scripts/docstrap.lib.js new file mode 100644 index 00000000..09d9272a --- /dev/null +++ b/docs/v3/scripts/docstrap.lib.js @@ -0,0 +1,11 @@ +if(!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){function c(a){var b="length"in a&&a.length,c=_.type(a);return"function"!==c&&!_.isWindow(a)&&(!(1!==a.nodeType||!b)||("array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a))}function d(a,b,c){if(_.isFunction(b))return _.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return _.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(ha.test(b))return _.filter(b,a,c);b=_.filter(b,a)}return _.grep(a,function(a){return U.call(b,a)>=0!==c})}function e(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}function f(a){var b=oa[a]={};return _.each(a.match(na)||[],function(a,c){b[c]=!0}),b}function g(){Z.removeEventListener("DOMContentLoaded",g,!1),a.removeEventListener("load",g,!1),_.ready()}function h(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=_.expando+h.uid++}function i(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(ua,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c||"false"!==c&&("null"===c?null:+c+""===c?+c:ta.test(c)?_.parseJSON(c):c)}catch(a){}sa.set(a,b,c)}else c=void 0;return c}function j(){return!0}function k(){return!1}function l(){try{return Z.activeElement}catch(a){}}function m(a,b){return _.nodeName(a,"table")&&_.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function n(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function o(a){var b=Ka.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function p(a,b){for(var c=0,d=a.length;d>c;c++)ra.set(a[c],"globalEval",!b||ra.get(b[c],"globalEval"))}function q(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(ra.hasData(a)&&(f=ra.access(a),g=ra.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)_.event.add(b,e,j[e][c])}sa.hasData(a)&&(h=sa.access(a),i=_.extend({},h),sa.set(b,i))}}function r(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&_.nodeName(a,b)?_.merge([a],c):c}function s(a,b){var c=b.nodeName.toLowerCase();"input"===c&&ya.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}function t(b,c){var d,e=_(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:_.css(e[0],"display");return e.detach(),f}function u(a){var b=Z,c=Oa[a];return c||(c=t(a,b),"none"!==c&&c||(Na=(Na||_("