All Projects → cca-io → rescript-react-intl-extractor

cca-io / rescript-react-intl-extractor

Licence: MIT license
Extracts messages for localization from ReScript source files.

Programming Languages

ocaml
1615 projects
Standard ML
205 projects
ReScript
86 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to rescript-react-intl-extractor

gatsby-typescript-emotion-storybook
Gatsby Starter: TypeScript + Emotion + Storybook + React Intl + SVGR + Jest
Stars: ✭ 63 (+96.88%)
Mutual labels:  react-intl
energy-use-case-trading-client
Energy Use Case Web UI for Lition Trading Platform
Stars: ✭ 23 (-28.12%)
Mutual labels:  react-intl
egghead-bookshelf
An example React application to accompany the "Add Internationalization (i18n) to a React app using React Intl" Egghead.io course
Stars: ✭ 28 (-12.5%)
Mutual labels:  react-intl
alda
A boilerplate for React isomorphic aplication with Material Design
Stars: ✭ 16 (-50%)
Mutual labels:  react-intl
rescript-react-intl
ReScript bindings to react-intl
Stars: ✭ 42 (+31.25%)
Mutual labels:  react-intl
react-intl-po-example
👉 This is a standalone project for using react-intl-po with CRA.
Stars: ✭ 38 (+18.75%)
Mutual labels:  react-intl
smashing-react-i18n
Internationalizing React App Boilerplate For SmashingMagazine
Stars: ✭ 63 (+96.88%)
Mutual labels:  react-intl
atticus-literature
Ititially, it's a bookstore website. However, I 'd like to develop something deeper then in the future.
Stars: ✭ 21 (-34.37%)
Mutual labels:  react-intl
admin-template-for-react
🌏 Admin template for React, React Redux, Redux Saga, React Router, i18n and integrated OAuth login
Stars: ✭ 83 (+159.38%)
Mutual labels:  react-intl
i18n
Minimalist gettext style i18n for JavaScript
Stars: ✭ 14 (-56.25%)
Mutual labels:  react-intl
react-intl-demo
使用 react-intl 实现 React 国际化多语言
Stars: ✭ 30 (-6.25%)
Mutual labels:  react-intl
mobx-react-intl
A connector between mobx-react and react-intl
Stars: ✭ 32 (+0%)
Mutual labels:  react-intl
generator-tsx
Yeoman generator for CRA + TypeScript + React + Redux + Router + Testing Library.
Stars: ✭ 25 (-21.87%)
Mutual labels:  react-intl
react-native-boilerplate
🚀 A highly scalable, react-native boilerplate reinforced with react-boilerplate which focus on performance and best practices. 🔥. 💻 🚀 😎 👾 👽
Stars: ✭ 82 (+156.25%)
Mutual labels:  react-intl
react-template
An enterprise react template application showcasing - Testing strategy, Global state management, middleware support, a network layer, component library integration, localization, PWA support, route configuration, lazy loading and CI/CD
Stars: ✭ 44 (+37.5%)
Mutual labels:  react-intl
react-intl-po
🚀 Extract POT from react-intl and convert back to json.
Stars: ✭ 88 (+175%)
Mutual labels:  react-intl
extract-react-intl
Extract react-intl messages
Stars: ✭ 18 (-43.75%)
Mutual labels:  react-intl
kotlin-js-wrappers
Kotlin JS wrappers for popular JavaScript libraries
Stars: ✭ 48 (+50%)
Mutual labels:  react-intl
react-intl-cra
🔧 Extract messages of Creact React App from the command line.
Stars: ✭ 68 (+112.5%)
Mutual labels:  react-intl
storybook-addon-intl
Addon to provide a locale switcher and react-intl for storybook
Stars: ✭ 84 (+162.5%)
Mutual labels:  react-intl

rescript-react-intl-extractor

Extracts messages for localization from ReScript source files.

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

NPM
Build Status

Installation

Binaries for macOS, Linux and Windows can be installed via npm or yarn. For global installation, run

npm install -g rescript-react-intl-extractor-bin

Alternatively, the binaries are also available for download on the releases page.

Usage

rescript-react-intl-extractor [--allow-duplicates] [path...]

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.

Output

The output (a JSON array of all extracted messages sorted by id) is written to stdout. It will look like this:

[
  {
    "id": "message.hello",
    "defaultMessage": "Hello"
  },
  {
    "id": "message.world",
    "defaultMessage": "World"
  },
  {
    "id": "some.message.id",
    "defaultMessage": "Some message"
  }
]

Message Definition (ReScript Syntax)

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

  1. inline in FormattedMessage:
<ReactIntl.FormattedMessage id="some.message.id" defaultMessage="Some message" />

or

open ReactIntl
...
<FormattedMessage id="some.message.id" defaultMessage="Some message" />
  1. within a module with the [@intl.messages] attribute:
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:

let foo = @intl.description("Hello description") {id: "message.hello", defaultMessage: "Hello"}

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.14.0.

Then run

opam pin add rescript-react-intl-extractor.dev . --no-action
opam install . --deps-only --with-doc --with-test

To build the project, run

opam exec -- dune build

To run the tests, do

opam exec -- dune runtest
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].