# babel-plugin-transform-format-message

> Pre-generate ids from default messages or inline a single language translation

Latest version **6.2.4** (published 2022-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-transform-format-message
pnpm add babel-plugin-transform-format-message
yarn add babel-plugin-transform-format-message
bun add babel-plugin-transform-format-message
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 6.2.4 |
| Published | 2022-02-17 |
| First published | 2015-11-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 58.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 206 |
| Author | Andy VanWagoner |
| Maintainers | thetalecrafter, bjohn465, aaronshaf, brentburgoyne |
| Keywords | format-message |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-transform-format-message
- Repository: https://github.com/format-message/format-message
- Homepage: https://github.com/format-message/format-message/tree/master/packages/babel-plugin-transform-format-message
- Issues: https://github.com/format-message/format-message/issues
- npm.io page: https://npm.io/package/babel-plugin-transform-format-message

## Dependencies (9)

- [source-map](https://npm.io/package/source-map.md) ^0.5.7
- [@babel/parser](https://npm.io/package/@babel/parser.md) ^7.0.0
- [format-message](https://npm.io/package/format-message.md) ^6.2.4
- [format-message-parse](https://npm.io/package/format-message-parse.md) ^6.2.4
- [lookup-closest-locale](https://npm.io/package/lookup-closest-locale.md) ^6.2.0
- [format-message-formats](https://npm.io/package/format-message-formats.md) ^6.2.4
- [format-message-estree-util](https://npm.io/package/format-message-estree-util.md) ^6.2.4
- [format-message-generate-id](https://npm.io/package/format-message-generate-id.md) ^6.2.4
- [@babel/helper-module-imports](https://npm.io/package/@babel/helper-module-imports.md) ^7.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 6.2.4 (latest) — 2022-02-17
- 6.0.0-alpha.2 (next) — 2018-04-18
- 6.2.3 — 2019-07-04
- 6.2.2 — 2019-07-04
- 6.2.1 — 2018-09-18
- 6.2.0 — 2018-09-12
- 6.1.0 — 2018-08-30
- 6.0.4 — 2018-06-05
- 6.0.3 — 2018-04-27
- 6.0.2 — 2018-04-23
- 6.0.1 — 2018-04-23
- 6.0.0 — 2018-04-19
- 6.0.0-alpha.1 — 2018-04-17
- 6.0.0-alpha.0 — 2018-04-16
- 5.2.6 — 2018-03-19
- … 21 more at https://npm.io/package/babel-plugin-transform-format-message/versions

## README

# babel-plugin-transform-format-message

> Pre-generate ids from default messages or inline a single language translation

[![npm Version][npm-image]][npm]
[![JS Standard Style][style-image]][style]
[![MIT License][license-image]][LICENSE]


## Installation

```sh
$ npm install babel-plugin-transform-format-message
```


## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```json
{
  "plugins": [ "transform-format-message", {
    "generateId": "underscored_crc32",
    "inline": false
  } ]
}
```

### Via CLI

```sh
$ babel --plugins transform-format-message script.js
```

### Via Node API

```javascript
require("babel-core").transform("code", {
  plugins: [
    [ "transform-format-message", {
      "generateId": "underscored_crc32",
      "translations": "./locales",
      "locale": "pt-BR"
    } ]
  ]
})
```

### Options

* `generateId` is either a function `string -> string`, or one of `"literal"`, `"normalized"`, `"underscored"`, `"underscored_crc32"`. Default is `"underscored_crc32"`.
* `inline` is a boolean. If true, the full translated message will be inlined and optimized, otherwise only generated ids will be added. Default is `false`.
* `locale` is the BCP 47 Language Tag string specifying the target language to inline. This is only used with `inline: true`. Default is `"en"`.
* `translations` is an object of the form: `{ [locale]: { [id]: { message: '...' }, ... } }`. This is an object with keys for each locale, with values matching the `extract-format-message` json output. This can also be a string path to require a module that exports a matching object.
* `missingTranslation` is one of `"ignore"`, `"warning"`, `"error"`. Default is `"warning"`.
* `missingReplacement` is an optional string to use in place of missing translations. By default the default message will be used.


License
-------

This software is free to use under the MIT license. See the [LICENSE-MIT file][LICENSE] for license text and copyright information.


[npm]: https://www.npmjs.org/package/babel-plugin-transform-format-message
[npm-image]: https://img.shields.io/npm/v/babel-plugin-transform-format-message.svg
[style]: https://github.com/feross/standard
[style-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[license-image]: https://img.shields.io/npm/l/format-message.svg
[LICENSE]: https://github.com/format-message/format-message/blob/master/LICENSE-MIT

---
_Source: https://npm.io/package/babel-plugin-transform-format-message · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
