You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: build.md
+24-25Lines changed: 24 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,40 +40,39 @@ Note that as `efunc` is defined as a `new Function()`, it has no access to the s
40
40
A [CLI compiler](https://github.com/messageformat/messageformat.js/tree/master/bin/messageformat.js) is also included, available as `./node_modules/.bin/messageformat` or just `messageformat` when installed with `npm install -g`.
-i, --inputdir directory containing messageformat files to compile
49
-
-o, --output output where messageformat will be compiled
50
-
-ns, --namespace global object in the output containing the templates
51
-
-I, --include glob patterns for files to include from `inputdir`
52
-
-m, --module create a commonJS module, instead of a global window variable
53
-
-s, --stdout print the result in stdout instead of writing in a file
54
-
-w, --watch watch `inputdir` for changes
55
-
-v, --verbose print logs for debug
56
-
```
57
-
58
-
`messageformat` will recursively read all JSON files in `inputdir` and compile them to `output`.
59
-
60
-
When using the CLI, the following commands will each produce the same results as included in the [examples](https://github.com/messageformat/messageformat.js/tree/master/example/en):
61
-
62
-
```
63
-
$ messageformat --locale en --namespace i18n --inputdir ./example/en --output ./i18n.js
64
-
$ messageformat --locale en ./example/en ./i18n.js
65
-
$ messageformat -l en ./example/en
43
+
$ messageformat
44
+
usage: messageformat [-l lc] [-n ns] [-p] input
45
+
46
+
Parses the input JSON file(s) of MessageFormat strings into a JS module of
47
+
corresponding hierarchical functions, written to stdout. Directories are
48
+
recursively scanned for all .json files.
49
+
50
+
-l lc, --locale=lc
51
+
The locale(s) lc to include; if multiple, selected by matching
52
+
message key. [default: en]
53
+
54
+
-n ns, --namespace=ns
55
+
The global object or modules format for the output JS. If ns does not
56
+
contain a '.', the output follows an UMD pattern. For module support,
57
+
the values 'export default' (ES6), 'exports' (CommonJS), and
58
+
'module.exports' (node.js) are special. [default: module.exports]
59
+
60
+
-p, --disable-plural-key-checks
61
+
By default, messageformat.js throws an error when a statement uses a
62
+
non-numerical key that will never be matched as a pluralization
63
+
category for the current locale. Use this argument to disable the
64
+
validation and allow unused plural keys. [default: false]
66
65
```
67
66
68
67
69
68
## Using compiled messageformat.js output
70
69
71
-
With default options, compiled messageformat functions are available through the `i18n`global object, with each source json having a corresponding subobject. Hence the compiled function corresponding to the `test` message defined in [`example/en/sub/folder/plural.json`](https://github.com/messageformat/messageformat.js/tree/master/example/en/sub/folder/plural.json) is available as [`i18n['sub/folder/plural'].plural`](https://github.com/messageformat/messageformat.js/tree/master/example/en/i18n.js):
70
+
With default options, compiled messageformat functions are available through `module.exports`. However, using e.g. `-n i18n`, an UMD pattern is used, falling back to a global `i18n`object, with each source json having a corresponding subobject. Hence the compiled function corresponding to the `test` message defined in [`example/en/sub/folder/plural.json`](https://github.com/messageformat/messageformat.js/tree/master/example/en/sub/folder/plural.json) is available as [`i18n.sub.folder.plural.test`](https://github.com/messageformat/messageformat.js/tree/master/example/en/i18n.js):
0 commit comments