# tablab-i18n

> Internationalized messages for tablab's failed write results

Latest version **1.0.1** (published 2024-11-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install tablab-i18n
pnpm add tablab-i18n
yarn add tablab-i18n
bun add tablab-i18n
```

## Health

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

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

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2024-11-03 |
| First published | 2022-03-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 84.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Raphael Jorge |
| Maintainers | raphaaj |
| Keywords | tablab, tablature, tabs, i18n, internationalization |

## Links

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

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

- 1.0.1 (latest) — 2024-11-03
- 1.0.0 — 2024-11-03
- 1.0.0-alpha.2 — 2023-05-02
- 1.0.0-alpha.1 — 2022-03-18
- 1.0.0-alpha.0 — 2022-03-14

## README

# tablab-i18n <!-- omit in toc -->

[![npm](https://img.shields.io/npm/l/tablab-i18n)](LICENSE)
[![npm](https://img.shields.io/npm/v/tablab-i18n)](https://www.npmjs.com/package/tablab-i18n)
[![npm](https://img.shields.io/npm/dt/tablab-i18n)](https://www.npmjs.com/package/tablab-i18n)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
[![Coverage Status](https://coveralls.io/repos/github/raphaaj/tablab-i18n/badge.svg?branch=main)](https://coveralls.io/github/raphaaj/tablab-i18n?branch=main)
[![CI](https://github.com/raphaaj/tablab-i18n/actions/workflows/ci.yml/badge.svg)](https://github.com/raphaaj/tablab-i18n/actions/workflows/ci.yml)

Internationalized messages for [tablab](https://github.com/raphaaj/tablab)'s failed write results.

## Table of Content <!-- omit in toc -->

- [Supported locales](#supported-locales)
- [Install](#install)
- [Usage](#usage)
- [License](#license)

## Supported locales

| Locale |  Language  | Localization Function |
| :----: | :--------: | :-------------------: |
| en-US  |  English   |    `localizeEnUs`     |
| pt-BR  | Portuguese |    `localizePtBr`     |

## Install

With [node](https://nodejs.org/en/) installed, run

```shell
npm install tablab-i18n
```

## Usage

The lib exposes the `localize` object and all the localization functions individually.

A localization function is responsible for localizing a collection of write results. It must be called with an array of write result objects. For each object, if it is a failed write result with a failure reason identifier defined by the lib [tablab](https://github.com/raphaaj/tablab), its failure message will be updated according to the given locale. Otherwise, the write result object will be kept unchanged.

The `localize` object maps a [supported locale](#supported-locales) to its corresponding localization function. Below is an example of how the `localize` object can be used to localize a collection of write results:

```js
const { Parser, Tab } = require('tablab');
const { localize } = require('tablab-i18n');

const instructions = '0-1';

const tab = new Tab();
const parser = new Parser();

const writeResults = parser
  .parseAll(instructions)
  .map((parsedInstruction) => parsedInstruction.writeOnTab(tab));

const locale = 'en-US'; // any supported locale
localize[locale](writeResults); // localize the failure message of all failed write results
```

Below is an example of how a specific localization function can be used to localize a collection of write results:

```js
const { Parser, Tab } = require('tablab');
const { localizeEnUs } = require('tablab-i18n');

const instructions = '0-1';

const tab = new Tab();
const parser = new Parser();

const writeResults = parser
  .parseAll(instructions)
  .map((parsedInstruction) => parsedInstruction.writeOnTab(tab));

localizeEnUs(writeResults); // localize the failure message of all failed write results (en-US)
```

## License

[MIT](LICENSE)

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