# @startupjs/babel-plugin-i18n-extract

> Extract translation keys

Latest version **0.63.1** (published 2026-06-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @startupjs/babel-plugin-i18n-extract
pnpm add @startupjs/babel-plugin-i18n-extract
yarn add @startupjs/babel-plugin-i18n-extract
bun add @startupjs/babel-plugin-i18n-extract
```

## Health

**Score 50/100 (C)** — status: active.

Positive: no vulnerabilities; high maintenance score.

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

## Facts

| | |
|---|---|
| Version | 0.63.1 |
| Published | 2026-06-24 |
| First published | 2021-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 109 |
| Author | Pavel Zhukov |
| Maintainers | cray0000, yska, zag2art, fctsvirus, maestro.sc, byshock, anagami, rabbit-abyss, tarlord, nariman322 |
| Keywords | babel, babel-plugin, react, i18n |

## Links

- npm: https://www.npmjs.com/package/@startupjs/babel-plugin-i18n-extract
- Repository: https://github.com/startupjs/startupjs
- Homepage: https://github.com/startupjs/startupjs#readme
- Issues: https://github.com/startupjs/startupjs/issues
- npm.io page: https://npm.io/package/@startupjs/babel-plugin-i18n-extract

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.17.20

## 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

- 0.63.1 (latest) — 2026-06-24
- 0.64.0-alpha.0 (alpha) — 2026-06-24
- 0.60.0-canary.7 (canary) — 2025-11-12
- 0.56.0-alpha.0 (next) — 2024-01-15
- 0.63.0 — 2026-06-24
- 0.63.0-alpha.0 — 2026-05-04
- 0.62.0 — 2026-05-04
- 0.62.0-alpha.6 — 2026-04-04
- 0.62.0-alpha.0 — 2026-03-25
- 0.61.0 — 2026-01-02
- 0.60.0-canary.0 — 2025-11-06
- 0.59.0-canary.0 — 2024-11-08
- 0.58.0-canary.0 — 2024-11-08
- 0.57.0-canary.75 — 2024-09-23
- 0.57.0-canary.0 — 2024-05-25
- … 34 more at https://npm.io/package/@startupjs/babel-plugin-i18n-extract/versions

## README

# @startupjs/babel-plugin-i18n-extract
> Babel Plugin for i18n Automation

This is a Babel plugin that automates i18n tasks by extracting translation keys and default values from your source code. It processes files with the following extensions: `js`, `jsx`, `ts`, `tsx`, `mjs`, `cjs`, `web.js`, `web.jsx`, `web.ts`, `web.tsx`, `web.mjs`, and `web.cjs`.

## Installation

To use this plugin, first install it as a dependency:

```bash
npm install --save-dev @startupjs/babel-plugin-i18n-extract
```

Then, add the plugin to your Babel configuration:

```json
{
  "plugins": ["@startupjs/babel-plugin-i18n-extract"]
}
```

## Usage

This plugin looks for the `t` function imported from the following libraries:

- `startupjs`
- `startupjs/i18n`
- `@startupjs/i18n`

The `t` function is used to mark strings for translation. It should be called with two string literal arguments: the translation key and the default value.

For example:

```jsx
import { observer, t } from 'startupjs';

export default observer(function App() {
  return <span>{t('key', 'defaultValue')}</span>;
});
```

During the build process, the plugin will extract the keys and default values and save them in a `translations.json` file.

## Configuration Options

The plugin accepts an optional `collectTranslations` configuration option:

```json
{
  "plugins": [
    ["@startupjs/babel-plugin-i18n-extract", { "collectTranslations": true }]
  ]
}
```

When `collectTranslations` is set to `true`, the plugin will merge the translations from different file extensions (web, android, ios) into a single translation object.

## Tests

The plugin includes tests to ensure it works correctly. The `__tests__/translations.spec.js` file checks if the generated `translations.json` file matches the expected content. The `__tests__/index.spec.js` file contains various test cases to ensure the plugin behaves as expected.

To run the tests, simply execute:

```bash
npm test
```

## License

This plugin is licensed under the [MIT License](LICENSE).

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