# @markuplint/i18n

> Internationalization for markuplint

Latest version **4.18.0** (published 2026-04-22) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; esm support; no vulnerabilities; has provenance; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.18.0 |
| Published | 2026-04-22 |
| First published | 2019-02-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 74.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 613 |
| Author | Yusuke Hirao |
| Maintainers | yusukehirao |

## Links

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

## Recent versions

- 4.18.0 (latest) — 2026-04-22
- 5.0.0-rc.7 (rc) — 2026-08-31
- 5.0.0-rc.1 (next) — 2026-03-27
- 5.0.0-dev.5 (canary) — 2026-02-27
- 3.0.0-alpha.27 (dev) — 2022-12-20
- 5.0.0-rc.6 — 2026-08-30
- 5.0.0-rc.5 — 2026-08-29
- 5.0.0-rc.4 — 2026-04-19
- 5.0.0-rc.2 — 2026-04-15
- 5.0.0-rc.0 — 2026-03-12
- 5.0.0-alpha.3 — 2026-02-26
- 5.0.0-alpha.2 — 2026-02-23
- 5.0.0-alpha.1 — 2026-02-22
- 5.0.0-alpha.0 — 2026-02-20
- 4.7.1 — 2026-02-10
- … 117 more at https://npm.io/package/@markuplint/i18n/versions

## README

# @markuplint/i18n

[![npm version](https://badge.fury.io/js/%40markuplint%2Fi18n.svg)](https://www.npmjs.com/package/@markuplint/i18n)

## Install

[`markuplint`](https://www.npmjs.com/package/markuplint) package includes this package.

<details>
<summary>If you are installing purposely, how below:</summary>

```shell
$ npm install @markuplint/i18n

$ yarn add @markuplint/i18n

```

</details>

## API

```ts
import { translator } from '@markuplint/i18n';

const t = translator({
  locale: 'ja',
  ...require('@markuplint/i18n/locales/ja.json'),
});
```

The `translator` function creates the `t` function.
It is an overloading function that accepts kind of arguments below:

### Translate sentence

```ts
type T = (template?: string, ...values: string[]) => string;
```

```ts
const message = t(
  // Template #1
  '{0} is {1:c}',
  // The {0} value of template #1
  t(
    // Template #2
    '{0} of {1}',
    // The {0} value of template #2
    t(
      // Template #3
      'the {0}',
      // The {0} value of template #3
      'value',
    ),
    // The {1} value of template #2
    t(
      // Template #4
      'the "{0*}" {1}',
      // The {0} value of template #4
      'id',
      // The {1} value of template #4
      'attribute',
    ),
  ),
  // The {1} value of template #1
  'duplicated',
);

console.log(message);
// => 属性「id」の値が重複しています
```

#### Placeholder

There is a placeholder that the number is surrounded by `{}` on template strings. It is replaced argument as a phrase. It translates the phrase if it matches the keyword defined in the dictionary.

#### Tagged templates syntax

:warning: It is experimental.

```ts
import { taggedTemplateTranslator } from '@markuplint/i18n';

const _ = taggedTemplateTranslator({
  locale: 'ja',
  ...require('path/to/dictionary/ja.json'),
});

const message = _`${
  //
  _`${
    //
    _`the ${'value'}`
  } of ${
    //
    _`the "${'id'}" ${'attribute'}`
  }`
} is ${
  //
  'c:duplicated'
}`;

console.log(message);
// => 属性「id」の値が重複しています
```

### Translate a phrase

```ts
type T = (phrase: string) => string;
```

```ts
const phrase = t('element');

console.log(phrase);
// => 要素
```

### Translate listed phrases

```ts
type T = (phrases: string[], useLastSeparator?: boolean) => string;
```

```ts
const list = t(['element', 'attribute', 'value']);

console.log(list);
// => 「要素」「属性」「値」

/* If locale is "en" */
console.log(list);
// => "element", "attribute", "value"
```

```ts
const list = t(['element', 'attribute', 'value'], true);

console.log(list);
// => 「要素」「属性」「値」

/* If locale is "en" */
console.log(list);
// => "element", "attribute" and "value"
```

It converts the character-separated list specified in each locale.

| Locale | Separator            | Before Char                | After Char                  | Last Separator                 |
| ------ | -------------------- | -------------------------- | --------------------------- | ------------------------------ |
| **en** | `, ` (comma + space) | `"` (double quote)         | `"` (double quote)          | `and` (space + chars + space ) |
| **ja** | none (empty string)  | `「` (left corner bracket) | `」` (right corner bracket) | none (empty string)            |

### Avoid translation

The `autocomplete` is defined as `オートコンプリート` in the **JA** dictionary.
However, It avoids translation if the number placeholder includes `*` (asterisk).
It is an effective means if you want a code or a specific name.

```ts
const phrase = t('the "{0}" {1}', 'autocomplete', 'attribute');
console.log(phrase);
// => 属性「オートコンプリート」

const phrase = t('the "{0*}" {1}', 'autocomplete', 'attribute');
console.log(phrase);
// => 属性「autocomplete」
```

Another means is that it surrounds `%` (percentage) to a phrase. It is effective when you use listing.

```ts
const phrase = t('the "{0}" {1}', '%autocomplete%', 'attribute');
console.log(phrase);
// => 属性「autocomplete」

const list = t(['element', '%attribute%', 'value']);
console.log(list);
// => 「要素」「attribute」「値」
```

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