# f-locale

> Localization helper for f-promise

Latest version **2.0.1** (published 2020-01-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install f-locale
pnpm add f-locale
yarn add f-locale
bun add f-locale
```

## Health

**Score 25/100 (F)** — status: abandoned.

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2020-01-14 |
| First published | 2017-05-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 2 |
| Unpacked size | 25.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Bruno Jouhier |
| Maintainers | bjouhier |
| Keywords | fibers, localization, i18n |

## Links

- npm: https://www.npmjs.com/package/f-locale
- Repository: https://github.com/Sage/f-locale
- Homepage: https://github.com/Sage/f-locale#readme
- Issues: https://github.com/Sage/f-locale/issues
- npm.io page: https://npm.io/package/f-locale

## Dependencies (2)

- [f-promise](https://npm.io/package/f-promise.md) ^2.0.8
- [handlebars](https://npm.io/package/handlebars.md) ^4.7.2

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

- 2.0.1 (latest) — 2020-01-14
- 2.0.0 — 2019-06-26
- 1.0.8 — 2017-07-13
- 1.0.7 — 2017-05-29
- 1.0.6 — 2017-05-29
- 1.0.5 — 2017-05-19
- 1.0.4 — 2017-05-19
- 1.0.3 — 2017-05-19
- 1.0.2 — 2017-05-18
- 1.0.1 — 2017-05-18
- 1.0.0 — 2017-05-18

## README

# f-locale

Localization helper for f-promise

`f-locale` is a companion package for [`f-promise`](https://github.com/Sage/f-promise).
It provides a small helper to manage localized messages.

## Installation

```sh
npm install --save f-locale
```

## Usage

Resources must be placed in JSON files inside a `resources` subdirectory of the current directory:

```sh
source-folder/
    resources/
        module1-en.json
        module1-fr.json
        ...
        module2-en.json
        module2-fr.json
        ...
    module1.ts
    module2.ts
```

The JSON files contain a simple object hash:

```json
{
    "simple": "a simple message",
    "complex": "a more complex message with {{0}} and {{1}} args"
}
```

`f-locale` uses [handlebars](http://handlebarsjs.com/) formatting directives.

Basic usage:

```js
import { locale } from 'f-locale';
const resources = locale.resources(module);

// setting the locale
locale.current = 'fr';
// loading a simple message
console.log(resources.message('simple'));
// formating a parameterized message
cconsole.log(resources.format('complex', 'hello', 5));
```

## License

MIT.

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