Package Exports
- y18n
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (y18n) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
y18n
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
pluralization support:
var __n = require('y18n').__n
console.log(__('%s fish %s', '%s 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:
directory
: the locale directory, default./locales
.updateFiles
: should newly observed strings be updated in file, defaulttrue
.locale
: what locale should be used.
y18n.__(str, arg, arg, arg)
Print a localized string, %s
will be replaced with arg
s.
y18n.__n(singularString, pluralString, count, arg, arg, arg)
Print a localized string with appropriate pluralization.
y18n.setLocale(str) TODO
Set the current locale being used.
y18n.getLocale() TODO
What locale is currently being used?
y18n.setLocale(obj) TODO
Update the current locale with the string lookups provided in obj
.
License
ISC