# @lion/localize

> The localization system helps to manage localization data split into locales and automate its loading

Latest version **0.26.0** (published 2022-09-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @lion/localize
pnpm add @lion/localize
yarn add @lion/localize
bun add @lion/localize
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.26.0 |
| Published | 2022-09-08 |
| First published | 2019-04-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 249.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1963 |
| Author | ing-bank |
| Maintainers | narzac, d4kmor |
| Keywords | lion, localize, web-components |

## Links

- npm: https://www.npmjs.com/package/@lion/localize
- Repository: https://github.com/ing-bank/lion
- Homepage: https://github.com/ing-bank/lion/
- Issues: https://github.com/ing-bank/lion/issues
- npm.io page: https://npm.io/package/@lion/localize

## Dependencies (3)

- [@lion/core](https://npm.io/package/@lion/core.md) ^0.24.0
- [singleton-manager](https://npm.io/package/singleton-manager.md) ^1.5.0
- [@bundled-es-modules/message-format](https://npm.io/package/@bundled-es-modules/message-format.md) 6.0.4

## Recent versions

- 0.26.0 (latest) — 2022-09-08
- 0.19.4 (lit1) — 2023-04-13
- 0.25.0 — 2022-05-31
- 0.19.3 — 2022-05-16
- 0.19.2 — 2022-05-09
- 0.19.1 — 2022-05-09
- 0.24.0 — 2022-04-06
- 0.23.0 — 2022-03-07
- 0.22.0 — 2022-01-04
- 0.21.3 — 2021-11-11
- 0.21.2 — 2021-10-19
- 0.21.1 — 2021-09-01
- 0.21.0 — 2021-07-21
- 0.20.2 — 2021-07-05
- 0.20.1 — 2021-06-16
- … 87 more at https://npm.io/package/@lion/localize/versions

## README

# Systems >> Localize >> Overview ||10

Is meant to translate text into multiple languages.
In it's simplest form it is a function that returns the translated text for a namespace + key.

## Features

- Uses es modules
- Formatting of numbers, amounts
- Formatting of dates

Further examples and a more in depth description can be found at the [Use Cases Page](https://github.com/ing-bank/lion/blob/650657231a4ec83592d45cd69836d28436635340/docs/fundamentals/systems/localize/use-cases.md).

## Content

| Feature                                  | Description                                   |
| ---------------------------------------- | --------------------------------------------- |
| [Translate Text](https://github.com/ing-bank/lion/blob/650657231a4ec83592d45cd69836d28436635340/docs/fundamentals/systems/localize/text.md)    | Load and translate text in multiple languages |
| [Format Numbers](https://github.com/ing-bank/lion/blob/650657231a4ec83592d45cd69836d28436635340/docs/fundamentals/systems/localize/numbers.md) | Format numbers in multiple languages          |
| [Format Dates](https://github.com/ing-bank/lion/blob/650657231a4ec83592d45cd69836d28436635340/docs/fundamentals/systems/localize/dates.md)     | Format dates in multiple languages            |

## Installation

```bash
npm i --save @lion/localize
```

```js
import { localize } from '@lion/localize';
```

### Example

The locale which will be loaded by default is accessed via the `localize.locale`.

The single source of truth for page's locale is `<html lang="my-LOCALE">`.
At the same time the interaction should happen via `localize.locale` getter/setter to be able to notify and react to the change.

```js
import { localize } from '@lion/localize.js';

localize.addEventListener('localeChanged', () => {
  // do smth when data is loaded for a new locale
});

// changes locale, syncs to `<html lang="es-ES">` and fires the event above
localize.locale = 'es-ES';
```

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