# @wordpress/i18n

> WordPress internationalization (i18n) library.

Latest version **6.28.0** (published 2026-09-10) · GPL-2.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @wordpress/i18n
pnpm add @wordpress/i18n
yarn add @wordpress/i18n
bun add @wordpress/i18n
```

Provides the command `pot-to-php`.

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.28.0 |
| Published | 2026-09-10 |
| First published | 2018-04-04 |
| Weekly downloads | 0 |
| License | GPL-2.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.12.0 |
| Dependencies | 4 |
| Unpacked size | 177.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11751 |
| Author | The WordPress Contributors |
| Maintainers | garypendergast, adamsilverstein, gziolo, ntwb, riad, noisysocks, kadamwhite, gutenbergplugin, jorgefilipecosta, ellatrix, iandunn206, whyisjake, ockham, sirreal, nosolosw, wpisabel, ntsekouras, nerrad, desrosj, talldanwp, peterwilsoncc, ryanwelcher, mamaduka, aduth, johnbillion |
| Keywords | wordpress, gutenberg, i18n |

## Links

- npm: https://www.npmjs.com/package/@wordpress/i18n
- Repository: https://github.com/WordPress/gutenberg
- Homepage: https://github.com/WordPress/gutenberg/tree/HEAD/packages/i18n/README.md
- Issues: https://github.com/WordPress/gutenberg/issues
- npm.io page: https://npm.io/package/@wordpress/i18n

## Dependencies (4)

- [tannin](https://npm.io/package/tannin.md) ^1.2.0
- [gettext-parser](https://npm.io/package/gettext-parser.md) ^1.3.1
- [@tannin/sprintf](https://npm.io/package/@tannin/sprintf.md) ^1.3.2
- [@wordpress/hooks](https://npm.io/package/@wordpress/hooks.md) ^4.55.0

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

- 6.28.0 (latest) — 2026-09-10
- 6.27.1-next.v.202609031004.0 (next) — 2026-09-03
- 6.13.1 (wp-7.0) — 2026-06-30
- 6.6.1 (wp-6.9) — 2025-10-28
- 5.19.1 (wp-6.8) — 2025-03-10
- 5.8.2 (wp-6.7) — 2024-09-30
- 5.0.1 (wp-6.6) — 2024-06-11
- 4.51.1 (wp-6.5) — 2024-02-20
- 4.42.13 (wp-6.4) — 2023-11-13
- 4.35.2 (wp-6.3) — 2023-10-12
- 4.26.2 (wp-6.2) — 2023-10-12
- 4.17.1 (wp-6.1) — 2022-09-20
- 4.6.1 (wp-6.0) — 2022-04-19
- 4.2.4 (wp-5.9) — 2021-11-15
- 4.1.2 (patch) — 2021-09-01
- … 243 more at https://npm.io/package/@wordpress/i18n/versions

## README

# Internationalization (i18n)

Internationalization utilities for client-side localization. See [How to Internationalize Your Plugin](https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/) for server-side documentation.

## Installation

Install the module:

```bash
npm install @wordpress/i18n --save
```

_This package assumes that your code will run in an **ES2015+** environment. If you're using an environment that has limited or no support for such language features and APIs, you should include [the polyfill shipped in `@wordpress/babel-preset-default`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/babel-preset-default#polyfill) in your code._

## Usage

```js
import { sprintf, _n } from '@wordpress/i18n';

sprintf( _n( '%d hat', '%d hats', 4, 'text-domain' ), 4 );
// 4 hats
```

For a complete example, see the [Internationalization section of the Block Editor Handbook](https://developer.wordpress.org/block-editor/developers/internationalization/).

## API

<!-- START TOKEN(Autogenerated API docs) -->

### createI18n

Create an i18n instance

_Parameters_

-   _initialData_ `[LocaleData< TextDomain >]`: Locale data configuration.
-   _initialDomain_ `[TextDomain]`: Domain for which configuration applies.
-   _hooks_ `[Hooks]`: Hooks implementation.

_Returns_

-   `I18n< TextDomain >`: I18n instance.

### defaultI18n

Default, singleton instance of `I18n`.

### getLocaleData

Returns locale data by domain in a Jed-formatted JSON object shape.

_Related_

-   <http://messageformat.github.io/Jed/>

_Parameters_

-   _domain_ `[ string | undefined ]`: Domain for which to get the data.

_Returns_

-   `LocaleData`: Locale data.

### hasTranslation

Check if there is a translation for a given string (in singular form).

_Parameters_

-   _single_ `string`: Singular form of the string to look up.
-   _context_ `string`: Context information for the translators.
-   _domain_ `string`: Domain to retrieve the translated text.

_Returns_

-   `boolean`: Whether the translation exists or not.

### isRTL

Check if current locale is RTL.

**RTL (Right To Left)** is a locale property indicating that text is written from right to left. For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages, including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).

_Returns_

-   `boolean`: Whether locale is RTL.

### resetLocaleData

Resets all current Tannin instance locale data and sets the specified locale data for the domain. Accepts data in a Jed-formatted JSON object shape.

_Related_

-   <http://messageformat.github.io/Jed/>

_Parameters_

-   _data_ `[LocaleData]`: Locale data configuration.
-   _domain_ `[string | undefined]`: Domain for which configuration applies.

### setLocaleData

Merges locale data into the Tannin instance by domain. Accepts data in a Jed-formatted JSON object shape.

_Related_

-   <http://messageformat.github.io/Jed/>

_Parameters_

-   _data_ `[LocaleData ]`: Locale data configuration.
-   _domain_ `[string | undefined]`: Domain for which configuration applies.

### sprintf

Returns a formatted string.

_Related_

-   <https://www.npmjs.com/package/@tannin/sprintf>

_Parameters_

-   _format_ `T | TransformedText< T >`: The format of the string to generate.
-   _args_ `DistributeSprintfArgs< T >`: Arguments to apply to the format.

_Returns_

-   `TransformedText< T >`: The formatted string.

### subscribe

Subscribes to changes of locale data

_Parameters_

-   _callback_ `SubscribeCallback`: Subscription callback

_Returns_

-   `UnsubscribeCallback`: Unsubscribe callback

### \_n

Translates and retrieves the singular or plural form based on the supplied number.

_Related_

-   <https://developer.wordpress.org/reference/functions/_n/>

_Parameters_

-   _single_ `Single`: The text to be used if the number is singular.
-   _plural_ `Plural`: The text to be used if the number is plural.
-   _number_ `number`: The number to compare against to use either the singular or plural form.
-   _domain_ `string | undefined`: Domain to retrieve the translated text.

_Returns_

-   `TransformedText<Single | Plural>`: The translated singular or plural form.

### \_nx

Translates and retrieves the singular or plural form based on the supplied number, with gettext context.

_Related_

-   <https://developer.wordpress.org/reference/functions/_nx/>

_Parameters_

-   _single_ `Single`: The text to be used if the number is singular.
-   _single_ `Single`: The text to be used if the number is singular.
-   _plural_ `Plural`: The text to be used if the number is plural.
-   _number_ `number`: The number to compare against to use either the singular or plural form.
-   _context_ `string`: Context information for the translators.
-   _domain_ `[string | undefined]`: Domain to retrieve the translated text.

_Returns_

-   `TransformedText<Single | Plural>`: The translated singular or plural form.

### \_x

Retrieve translated string with gettext context.

_Related_

-   <https://developer.wordpress.org/reference/functions/_x/>

_Parameters_

-   _text_ `Text`: Text to translate.
-   _context_ `string`: Context information for the translators.
-   _domain_ `string | undefined`: Domain to retrieve the translated text.

_Returns_

-   `TransformedText<Text>`: Translated context string without pipe.

### \_\_

Retrieve the translation of text.

_Related_

-   <https://developer.wordpress.org/reference/functions/__/>

_Parameters_

-   _text_ `Text`: Text to translate.
-   _domain_ `string | undefined`: Domain to retrieve the translated text.

_Returns_

-   `TransformedText<Text>`: Translated text.

<!-- END TOKEN(Autogenerated API docs) -->

## Contributing to this package

This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).

<br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>

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