Skip to content

Commit 00eba6e

Browse files
authored
Update docs (#66)
* Update changelog for 0.10.0 * Update README for ReScript support.
1 parent 0a366fd commit 00eba6e

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.10.0 - 2021-01-10
4+
5+
- Added ReScript support (ReScript 7cc70c9). 🎉
6+
- Removed support for bs-react-intl 1.x style message definition.
7+
- Downgraded to OCaml 4.06 to be able to build ReScript parser.
8+
39
## 0.9.1 - 2020-11-15
410

511
- Added optional description support for message records via `@intl.description` attribute.

README.md

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# bs-react-intl-extractor
22

3-
Extracts messages for localization from [Reason] source files.
3+
Extracts messages for localization from [ReScript] or [Reason] source files.
44
This assumes that you are using the [bs-react-intl] 2.x bindings for [react-intl].
55

66
[![NPM](https://nodei.co/npm/bs-react-intl-extractor-bin.png?compact=true)](https://nodei.co/npm/bs-react-intl-extractor-bin/)
@@ -22,7 +22,7 @@ Alternatively, the binaries are also available for download on the [releases pag
2222
bs-react-intl-extractor [--allow-duplicates] [path...]
2323
```
2424

25-
where `path` is a Reason source file or a directory containing Reason source files. Multiple files/directories may be specified.
25+
where `path` is a ReScript (`*.res`) or Reason (`*.re`) source file or a directory containing such source files. Multiple files/directories may be specified.
2626

2727
The `--allow-duplicates` option allows messages with identical `id` props if the `defaultMessage` props are identical as well.
2828

@@ -47,7 +47,44 @@ The output (a JSON array of all extracted messages sorted by id) is written to s
4747
]
4848
```
4949

50-
## Message Definition
50+
## Message Definition (ReScript Syntax)
51+
52+
Formatted messages may be defined in your source files in one of the following ways:
53+
54+
1. inline in `FormattedMessage`:
55+
56+
```rescript
57+
<ReactIntl.FormattedMessage id="some.message.id" defaultMessage="Some message" />
58+
```
59+
60+
or
61+
62+
```rescript
63+
open ReactIntl;
64+
...
65+
<FormattedMessage id="some.message.id" defaultMessage="Some message" />
66+
```
67+
68+
2. within a module with the `[@intl.messages]` attribute:
69+
70+
```rescript
71+
open ReactIntl
72+
73+
module Msg = {
74+
@@intl.messages
75+
76+
let hello = {id: "message.hello", defaultMessage: "Hello"}
77+
let world = {id: "message.world", defaultMessage: "World"}
78+
}
79+
```
80+
81+
You also can pass descriptions to the records with:
82+
83+
```rescript
84+
let foo = @intl.description("Hello description") {id: "message.hello", defaultMessage: "Hello"}
85+
```
86+
87+
## Message Definition (Reason Syntax)
5188

5289
Formatted messages may be defined in your source files in one of the following ways:
5390

@@ -86,6 +123,10 @@ let foo = [@intl.description "Hello description"] {id: "message.hello", defaultM
86123

87124
## Building and Testing
88125

126+
The ReScript parser is included as a git submodule. Therefore, after checking out the sources, first run
127+
128+
git submodule update --init --recursive
129+
89130
Install [esy] as follows:
90131

91132
% npm install -g esy
@@ -106,6 +147,7 @@ Run the tests:
106147

107148
% esy test
108149

150+
[rescript]: https://rescript-lang.org/
109151
[reason]: https://reasonml.github.io
110152
[bs-react-intl]: https://github.com/alexfedoseev/bs-react-intl
111153
[react-intl]: https://github.com/yahoo/react-intl

0 commit comments

Comments
 (0)