# spa-gettext

> Application localization tools.

Latest version **1.4.1** (published 2018-08-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install spa-gettext
pnpm add spa-gettext
yarn add spa-gettext
bun add spa-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.4.1 |
| Published | 2018-08-14 |
| First published | 2015-12-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Stanislav Kalashnik |
| Maintainers | spasdk |
| Keywords | spa, sdk, spasdk, framework, gettext, localization |

## Links

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

## Dependencies (2)

- [cjs-emitter](https://npm.io/package/cjs-emitter.md) ^1.5.3
- [cjs-gettext](https://npm.io/package/cjs-gettext.md) ^1.0.4

## 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.4.1 (latest) — 2018-08-14
- 1.4.0 — 2016-10-25
- 1.3.0 — 2015-12-28

## README

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

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


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 spa-gettext
```


## Usage ##

Add to the scope:

```js
var gettext = require('spa-gettext');
```

Load localization messages file (`./lang/ru.json`):

```js
gettext.load({name: 'ru'}, function ( error ) {
    console.log(error);
});
```

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

```js
console.log(gettext('some line to be localized'));
```

Fetch a particular translation of the textual message:

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

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

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

It's also possible to listen to instance events (`load` and `error`):

```js
gettext.addListener('load', function () {
    // handle localization loading
});

gettext.addListener('error', function () {
    // handle localization loading
});
```

On localization loading for `en` language real AJAX request is not executed.
There is `loader.defaultLanguage` option to control this behaviour.


## 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 problem or suggestion please open an issue [here](https://github.com/spasdk/gettext/issues).
Pull requests are welcomed with respect to the [JavaScript Code Style](https://github.com/DarkPark/jscs).


## License ##

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

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