# @vscode/l10n

> A helper library to assist in localizing subprocesses spun up by VS Code extensions

Latest version **0.0.18** (published 2023-12-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vscode/l10n
pnpm add @vscode/l10n
yarn add @vscode/l10n
bun add @vscode/l10n
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.18 |
| Published | 2023-12-10 |
| First published | 2022-09-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 114 |
| Author | Microsoft Corporation |
| Maintainers | microsoft1es, joaomoreno.ms, sbatten, alexandrudima, lszomoru, kaimaetzel, vscode-bot |

## Links

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

## Recent versions

- 0.0.18 (latest) — 2023-12-10
- 0.0.17 — 2023-11-27
- 0.0.16 — 2023-07-21
- 0.0.15 — 2023-07-08
- 0.0.14 — 2023-05-04
- 0.0.13 — 2023-03-31
- 0.0.11 — 2023-01-20
- 0.0.10 — 2022-11-13
- 0.0.9 — 2022-11-10
- 0.0.7 — 2022-11-09
- 0.0.8 — 2022-11-08
- 0.0.6 — 2022-11-02
- 0.0.5 — 2022-10-14
- 0.0.3 — 2022-09-27
- 0.0.2 — 2022-09-09
- … 1 more at https://npm.io/package/@vscode/l10n/versions

## README

# @vscode/l10n

Library used for loading the translations into subprocesses of your extension. These usages also get picked up by [l10n-dev](https://github.com/microsoft/vscode-l10n/tree/main/l10n-dev) string extraction tooling.

> **Note**
>
> You should _NOT_ use this library in your extension's main process. The translations are loaded into the main process by VS Code itself.

## Usage

```typescript
import * as l10n from '@vscode/l10n';

// Load the translations for the current locale
l10n.config({
    contents: JSON.parse(process.env.BUNDLE_FROM_EXTENSION)
});
// or
l10n.config({
    fsPath: process.env.FSPATH_TO_BUNDLE_FROM_EXTENSION
});
// or (warning, this is async)
await l10n.config({
    uri: JSON.parse(process.env.BUNDLE_URI_FROM_EXTENSION)
});

// returns the translated string or the original string if no translation is available
l10n.t('Hello World');

// supports arguments just like the vscode API
l10n.t('Hello {0}', 'John');

// supports comments for translators
l10n.t({
    message: 'Hello {0}',
    args: ['John'],
    comment: ['This is a comment']
});
```

The input for `l10n.config` pairs nicely with the `bundle` and `uri` properties on the `l10n` namespace that are provided by the [VS Code API](https://code.visualstudio.com/api/references/vscode-api#l10n).
You should send the value of one of these properties from your extension to your subprocess that is consuming `@vscode/l10n`.

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