Skip to content

Commit

Permalink
Update CHANGELOG and README
Browse files Browse the repository at this point in the history
  • Loading branch information
cknitt committed Sep 18, 2022
1 parent 429c099 commit 8fa467e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 49 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.13.0 - 2022-09-18

- Updated ReScript parser version to 241fefd (ReScript 10.0.1).
- Removed Reason support.
- Unescape extracted strings to fix issue with duplicate newlines.
- Build with OCaml 4.14.0.
- Perform Linux build on ubuntu-20.04 as ubuntu-18.04 is deprecated.

## 0.12.0 - 2021-05-29

- [bs-react-intl-ppx](https://github.com/ahrefs/bs-react-intl-ppx) support added.
Expand Down
52 changes: 3 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rescript-react-intl-extractor

Extracts messages for localization from [ReScript] source files. Also supports the legacy [Reason] syntax.
Extracts messages for localization from [ReScript] source files.

This assumes that you are using the [rescript-react-intl] bindings for [react-intl].

Expand All @@ -23,7 +23,7 @@ Alternatively, the binaries are also available for download on the [releases pag
rescript-react-intl-extractor [--allow-duplicates] [path...]
```

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

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

Expand Down Expand Up @@ -85,58 +85,13 @@ You also can pass descriptions to the records with:
let foo = @intl.description("Hello description") {id: "message.hello", defaultMessage: "Hello"}
```

## Message Definition (Legacy Reason Syntax)

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

1. inline in `FormattedMessage`:

```reason
<ReactIntl.FormattedMessage id="some.message.id" defaultMessage="Some message" />
```

or

```reason
open ReactIntl;
...
<FormattedMessage id="some.message.id" defaultMessage="Some message" />
```

2. within a module with the `[@intl.messages]` attribute:

```reason
open ReactIntl;
module Msg = {
[@intl.messages];
let hello = {id: "message.hello", defaultMessage: "Hello"};
let world = {id: "message.world", defaultMessage: "World"};
};
```

You also can pass descriptions to the records with:

```reason
let foo = [@intl.description "Hello description"] {id: "message.hello", defaultMessage: "Hello"};
```

3. within [intl-ppx](https://github.com/ahrefs/bs-react-intl-ppx)
[ReScript team recommends not to use PPXes](https://forum.rescript-lang.org/t/some-thoughts-on-community-building/1474/25)

```reason
let hello = [%intl "hello"]
let world = [%intl {msg: "world", desc: "Some description"}]
```

## Building and Testing

The ReScript parser is included as a git submodule. Therefore, after checking out the sources, first run

git submodule update --init --recursive

Install Ocaml and OPAM, and create an OPAM switch with OCaml version 4.06.1.
Install OCaml and OPAM, and create an OPAM switch with OCaml version 4.14.0.

Then run

Expand All @@ -152,7 +107,6 @@ To run the tests, do
opam exec -- dune runtest

[rescript]: https://rescript-lang.org/
[reason]: https://reasonml.github.io
[rescript-react-intl]: https://github.com/cca-io/rescript-react-intl
[bs-react-intl-ppx]: https://github.com/ahrefs/bs-react-intl-ppx
[react-intl]: https://github.com/yahoo/react-intl
Expand Down

0 comments on commit 8fa467e

Please sign in to comment.