# rollup-plugin-i18n

> Embed localization in your bundle

Latest version **0.3.1** (published 2018-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-i18n
pnpm add rollup-plugin-i18n
yarn add rollup-plugin-i18n
bun add rollup-plugin-i18n
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2018-07-04 |
| First published | 2017-03-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 98.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Minh Pham |
| Maintainers | phamtm |
| Keywords | rollup-plugin, i18n, rollup |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-i18n
- Repository: https://github.com/phamtm/rollup-plugin-i18n
- Homepage: https://github.com/phamtm/rollup-plugin-i18n#readme
- Issues: https://github.com/phamtm/rollup-plugin-i18n/issues
- npm.io page: https://npm.io/package/rollup-plugin-i18n

## Dependencies (1)

- [rollup-pluginutils](https://npm.io/package/rollup-pluginutils.md) ^2.0.1

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2018-07-04
- 0.3.0 — 2017-11-26
- 0.2.2 — 2017-06-11
- 0.2.1 — 2017-03-30
- 0.2.0 — 2017-03-30

## README

# rollup-plugin-i18n

Embed your localized text into your bundle.

## How to use
In your source code, for example if you have a key called 'msg_hello', to translate it use `__('msg_hello')`

## Config

```js
import i18n from 'rollup-plugin-i18n';

export default {
  entry: 'index.js',
  plugins: [
    i18n({
      language: {
        'msg_hello': 'Hello',
        'msg_world': 'World!',
      },
    }),
  ],
}
```

```js
// index.js

console.log(__('msg_hello'), __('msg_world'));

```

### Output
```
Hello World!
```

### Options
- `language: {[key:string]: string}`: an object that map from a string key to the localized message

### Limitations
Currently we are using a regex to replace all instances of `__(<msg>)` with their translation. In the future if rollup decides to open up access to the AST we can do a better job of replacement.

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