# cjs-gettext

> Application localization tools.

Latest version **1.0.5** (published 2018-10-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install cjs-gettext
pnpm add cjs-gettext
yarn add cjs-gettext
bun add cjs-gettext
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2018-10-16 |
| First published | 2016-10-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Stanislav Kalashnik |
| Maintainers | cjssdk |
| Keywords | commonjs, cjs, sdk, cjssdk, framework, gettext, localization |

## Links

- npm: https://www.npmjs.com/package/cjs-gettext
- Repository: https://github.com/cjssdk/gettext
- Homepage: https://github.com/cjssdk/gettext#readme
- Issues: https://github.com/cjssdk/gettext/issues
- npm.io page: https://npm.io/package/cjs-gettext

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 1.0.5 (latest) — 2018-10-16
- 1.0.4 — 2018-08-04
- 1.0.2 — 2017-08-09
- 1.0.1 — 2017-03-06
- 1.0.0 — 2016-10-19

## README

STB SDK localization
====================

[![build status](https://img.shields.io/travis/cjssdk/gettext.svg?style=flat-square)](https://travis-ci.org/cjssdk/gettext)
[![npm version](https://img.shields.io/npm/v/cjs-gettext.svg?style=flat-square)](https://www.npmjs.com/package/cjs-gettext)
[![dependencies status](https://img.shields.io/david/cjssdk/gettext.svg?style=flat-square)](https://david-dm.org/cjssdk/gettext)
[![devDependencies status](https://img.shields.io/david/dev/cjssdk/gettext.svg?style=flat-square)](https://david-dm.org/cjssdk/gettext?type=dev)
[![Gitter](https://img.shields.io/badge/gitter-join%20chat-blue.svg?style=flat-square)](https://gitter.im/DarkPark/cjssdk)
[![RunKit](https://img.shields.io/badge/RunKit-try-yellow.svg?style=flat-square)](https://npm.runkit.com/cjs-gettext)


This localization module is an instance of [Emitter](https://github.com/cjssdk/emitter) module.
Contains localization messages data used by other modules and provides methods to requests these messages.


## Installation ##

```bash
npm install cjs-gettext
```


## Usage ##

Example `data` format:

```json
{
    "meta": {
        "charset": "utf-8",
        "project": "downloads",
        "language": "ru",
        "plural": "(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)"
    },
    "data": {
        "": {
            "some text": "некоторый текст",
            "Close": "Закрыть",
            "Error": "Ошибка",
            "File name:": "Имя файла:",
        },
        "some context": {
            "some text": "Лирика",
            "Close": "Выйти",
            "Error": "Недопустимое действие",
        }

    }
}
```


Add the constructor to the scope and create an instance with some data:

```js
var Gettext = require('cjs-gettext'),
    gettext = new Gettext(data);
```

Then it's possible to make direct calls to make simple replacement:

```js
console.log(gettext.gettext('Close'));
```

Fetch a particular translation of the textual message:

```js
console.log(gettext.pgettext('some context', 'some text'));
```

Native language translation of a textual message whose grammatical form depends on a number:

```js
console.log(gettext.ngettext('{0} cat', '{0} cats', 1));
```


## Development mode ##

> There is a global var `DEVELOP` which activates additional consistency checks and protection logic not available in release mode.


## Contribution ##

If you have any problems or suggestions please open an [issue](https://github.com/cjssdk/gettext/issues)
according to the contribution [rules](.github/contributing.md).


## License ##

`cjs-gettext` is released under the [MIT License](license.md).

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