Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cjs-gettext

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cjs-gettext

Application localization tools.

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-70%
Maintainers
1
Weekly downloads
 
Created
Source

STB SDK localization

build status npm version dependencies status devDependencies status Gitter RunKit

This localization module is an instance of Emitter module. Contains localization messages data used by other modules and provides methods to requests these messages.

Installation

npm install cjs-gettext

Usage

Example data format:

{
    "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:

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

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

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

Fetch a particular translation of the textual message:

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

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

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 according to the contribution rules.

License

cjs-gettext is released under the MIT License.

Keywords

FAQs

Package last updated on 16 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc