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
{{ message }}
This repository was archived by the owner on May 4, 2020. It is now read-only.
--pragma <pragma> parse specific additional custom pragma. This allows you to tag certain file with metadata such as `project`. For example with this file:
```
// @intl-meta project:my-custom-project
import {FormattedMessage} from 'react-intl';
<FormattedMessage defaultMessage="foo" id="bar" />;
```
and with option `{pragma: "@intl-meta"}`, we'll parse out `// @intl-meta project:my-custom-project` into `{project: 'my-custom-project'}` in the result file.
Copy file name to clipboardExpand all lines: packages/cli/README.md
+28-30Lines changed: 28 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,44 +5,42 @@ including React components that uses `react-intl`.
5
5
6
6
## Usage
7
7
8
-
```shell
8
+
````shell
9
9
$ npm -g i @formatjs/cli
10
10
$ formatjs extract --help
11
11
Usage: formatjs extract [options] [files...]
12
+
Usage: formatjs extract [options] [files...]
13
+
12
14
Extract string messages from React components that use react-intl.
13
15
The input language is expected to be TypeScript or ES2017 with JSX.
14
16
15
17
Options:
16
-
--messages-dir <dir> The target location where the plugin will output a `.json` file
17
-
corresponding to each component from which React Intl messages
18
-
were extracted. If not provided, the extracted message
18
+
--messages-dir <dir> The target location where the plugin will output a `.json` file corresponding to each component from which React Intl messages were extracted. If not provided, the extracted message
19
19
descriptors will be printed to standard output.
20
-
--out-file <path> The target file path where the plugin will output an aggregated \`.json\` file of allthe translations from the \`files\`
21
-
supplied.
20
+
--out-file <path> The target file path where the plugin will output an aggregated `.json` file of allthe translations from the `files` supplied.
22
21
This flag will ignore --messages-dir
23
-
--id-interpolation-pattern <pattern> If certain message descriptors don\'t have id, this \`pattern\` will be used to automaticallygenerate IDs for them. Default to
24
-
\`[contenthash:5]\`.
22
+
--id-interpolation-pattern <pattern> If certain message descriptors don't have id, this `pattern` will be used to automaticallygenerate IDs for them. Default to `[contenthash:5]`.
25
23
See https://github.com/webpack/loader-utils#interpolatename for sample patterns
26
-
--extract-source-location Whether the metadata about the location of the message in the
27
-
source file should be extracted. If `true`, then`file`,
28
-
`start`, and `end` fields will exist for each extracted message
29
-
descriptors. (default: false)
30
-
--module-source-name <name> The ES6 module source name of the React Intl package. Defaults
31
-
to: `"react-intl"`, but can be changed to another name/path to
32
-
React Intl.
33
-
--remove-default-message Remove `defaultMessage` field in generated js after extraction
34
-
(default: false)
35
-
--additional-component-names <comma-separated-names> Additional component names to extract messages from, e.g:
36
-
`['FormattedFooBarMessage']`. **NOTE**: By default we check for
37
-
the fact that `FormattedMessage` are
38
-
imported from `moduleSourceName` to make sure variable alias
39
-
works. This option does not do that so it's less safe.
40
-
--extract-from-format-message-call Opt-in to extract from `intl.formatMessage` call with the same
41
-
restrictions, e.g: has to be called with object literal such as
--ignore List of glob paths to **not** extract translations from.
45
-
--output-empty-json Output file with empty [] if src has no messages. For build systems like bazel that relies on specific output mapping, not writing out a file can cause issues.
24
+
--extract-source-location Whether the metadata about the location of the message in the source file should be extracted. If `true`, then `file`, `start`, and `end` fields will exist for each extracted
25
+
message descriptors. (default: false)
26
+
--module-source-name <name> The ES6 module source name of the React Intl package. Defaults to: `"react-intl"`, but can be changed to another name/path to React Intl.
27
+
--remove-default-message Remove `defaultMessage` field in generated js after extraction (default: false)
28
+
--additional-component-names <comma-separated-names> Additional component names to extract messages from, e.g: `['FormattedFooBarMessage']`. **NOTE**: By default we check for the fact that `FormattedMessage` is imported from
29
+
`moduleSourceName` to make sure variable alias works. This option does not do that so it's less safe.
30
+
--extract-from-format-message-call Opt-in to extract from `intl.formatMessage` call with the same restrictions, e.g: has to be called with object literal such as `intl.formatMessage({ id: 'foo', defaultMessage:
31
+
'bar', description: 'baz'})` (default: false)
32
+
--output-empty-json Output file with empty [] if src has no messages. For build systems like bazel that relies on specific output mapping, not writing out a file can cause issues. (default: false)
33
+
--ignore <files> List of glob paths to **not** extract translations from.
46
34
--throws Whether to throw an exception when we fail to process any file in the batch.
47
-
-h, --help output usage information
48
-
```
35
+
--pragma <pragma> parse specific additional custom pragma. This allows you to tag certain file with metadata such as `project`. For example with this file:
and with option `{pragma: "@intl-meta"}`, we'll parse out `// @intl-meta project:my-custom-project` into `{project: 'my-custom-project'}` in the result file.
and with option \`{pragma: "@intl-meta"}\`, we'll parse out \`// @intl-meta project:my-custom-project\` into \`{project: 'my-custom-project'}\` in the result file.`
Copy file name to clipboardExpand all lines: packages/cli/tests/extract/integration_tests/__snapshots__/index.test.ts.snap
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -230,6 +230,16 @@ Options:
230
230
--output-empty-json Output file with empty [] if src has no messages. For build systems like bazel that relies on specific output mapping, not writing out a file can cause issues. (default: false)
231
231
--ignore <files> List of glob paths to **not** extract translations from.
232
232
--throws Whether to throw an exception when we fail to process any file in the batch.
233
+
--pragma <pragma> parse specific additional custom pragma. This allows you to tag certain file with metadata such as \`project\`. For example with this file:
and with option \`{pragma: \\"@intl-meta\\"}\`, we'll parse out \`// @intl-meta project:my-custom-project\` into \`{project: 'my-custom-project'}\` in the result file.
0 commit comments