/ stream.nieuweinstituut.nl / node_modules / y18n /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[TXT]CHANGELOG.md40 years ago1.2K 
[   ]LICENSE40 years ago731  
[TXT]README.md40 years ago2.8Kd768d73 docs [كارل مبارك]
[   ]index.js40 years ago5.1K3e510ca test new git [كارل مبارك]
[   ]package.json2 years ago1.7K3e510ca test new git [كارل مبارك]
README.md

y18n

Build Status Coverage Status NPM version js-standard-style Conventional Commits

The bare-bones internationalization library used by yargs.

Inspired by i18n.

Examples

simple string translation:

var __ = require('y18n').__

console.log(__('my awesome string %s', 'foo'))

output:

my awesome string foo

using tagged template literals

var __ = require('y18n').__
var str = 'foo'

console.log(__`my awesome string ${str}`)

output:

my awesome string foo

pluralization support:

var __n = require('y18n').__n

console.log(__n('one fish %s', '%d fishes %s', 2, 'foo'))

output:

2 fishes foo

JSON Language Files

The JSON language files should be stored in a ./locales folder. File names correspond to locales, e.g., en.json, pirate.json.

When strings are observed for the first time they will be added to the JSON file corresponding to the current locale.

Methods

require('y18n')(config)

Create an instance of y18n with the config provided, options include:

y18n.__(str, arg, arg, arg)

Print a localized string, %s will be replaced with args.

This function can also be used as a tag for a template literal. You can use it like this: __`hello ${'world'}`. This will be equivalent to __('hello %s', 'world').

y18n.__n(singularString, pluralString, count, arg, arg, arg)

Print a localized string with appropriate pluralization. If %d is provided in the string, the count will replace this placeholder.

y18n.setLocale(str)

Set the current locale being used.

y18n.getLocale()

What locale is currently being used?

y18n.updateLocale(obj)

Update the current locale with the key value pairs in obj.

License

ISC

Apache/2.4.38 (Debian) Server at www.karls.computer Port 80