Socket
Book a DemoInstallSign in
Socket

jr-translate

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jr-translate

simple translate module with plurals

latest
Source
npmnpm
Version
2.0.1
Version published
Maintainers
1
Created
Source

Translate module (Internationalization)

translate key to lang value, using multiple language format

##how to use:

    translate(<lang, ...optional>, <groupPath>, <data, ...optional>) - default usage

    addPlural(<PluData>) - register new plural formatter

    addBlock(<BlockData>) - register new block with translates

    getLang(); - return [string] of current language

    setLang(<string>) - set new language for translates

    getNumber(<number>) - return number in locale format

samples:

 import {translate, getNumber, getLang, setLang} from 'jr-translate';

 const text = translate('group.key'); // default usage

 const numberLocale = getNumber(number); // return number in locale format

 const currLang = getLang(); // current lang

 setLang(newLang); // set new language for translates

 const text = translate('group.key', {
    dataKey: 'value'
 }); // with data pass

adding new langs

 import {addBlock} from 'jr-translate'; // module not binded to context
 import exampleBlock from './example.langs.ts';

 addBlock(exampleBlock); // make new langs for translates

licence: MIT, dudiq 2022

Keywords

translate

FAQs

Package last updated on 28 May 2022

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