Socket
Socket
Sign inDemoInstall

y18n

Package Overview
Dependencies
0
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

.travis.yml

16

index.js

@@ -118,2 +118,18 @@ var fs = require('fs')

Y18N.prototype.setLocale = function (locale) {
this.locale = locale
}
Y18N.prototype.getLocale = function () {
return this.locale
}
Y18N.prototype.updateLocale = function (obj) {
if (!this.cache[this.locale]) this._readLocaleFile()
for (var key in obj) {
this.cache[this.locale][key] = obj[key]
}
}
module.exports = function (opts) {

@@ -120,0 +136,0 @@ var y18n = new Y18N(opts)

6

package.json
{
"name": "y18n",
"version": "1.0.0",
"version": "1.1.0",
"description": "the bare-bones internationalization library used by yargs",

@@ -8,3 +8,4 @@ "main": "index.js",

"pretest": "standard",
"test": "nyc mocha"
"test": "nyc mocha",
"coverage": "nyc report --reporter=text-lcov | coveralls"
},

@@ -28,2 +29,3 @@ "repository": {

"chai": "^3.2.0",
"coveralls": "^2.11.3",
"mocha": "^2.2.5",

@@ -30,0 +32,0 @@ "nyc": "^3.0.1",

# y18n
[![Build Status][travis-image]][travis-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![NPM version][npm-image]][npm-url]
[![js-standard-style][standard-image]][standard-url]
The bare-bones internationalization library used by yargs.

@@ -59,13 +64,13 @@

### y18n.setLocale(str) __TODO__
### y18n.setLocale(str)
Set the current locale being used.
### y18n.getLocale() __TODO__
### y18n.getLocale(locale)
What locale is currently being used?
### y18n.setLocale(obj) __TODO__
### y18n.updateLocale(obj)
Update the current locale with the string lookups provided in `obj`.
Update the current locale with the key value pairs in `obj`.

@@ -75,1 +80,10 @@ ## License

ISC
[travis-url]: https://travis-ci.org/bcoe/y18n
[travis-image]: https://img.shields.io/travis/bcoe/y18n.svg
[coveralls-url]: https://coveralls.io/github/bcoe/y18n
[coveralls-image]: https://img.shields.io/coveralls/bcoe/y18n.svg
[npm-url]: https://npmjs.org/package/y18n
[npm-image]: https://img.shields.io/npm/v/y18n.svg
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[standard-url]: https://github.com/feross/standard

@@ -201,2 +201,56 @@ /* global describe, it, after, beforeEach */

describe('setLocale', function () {
it('switches the locale', function () {
var i18n = y18n({
directory: __dirname + '/locales'
})
i18n.__('Hello').should.equal('Hello!')
i18n.setLocale('pirate')
i18n.__('Hello').should.equal('Avast ye mateys!')
})
})
describe('updateLocale', function () {
beforeEach(function (done) {
rimraf('./test/locales/fr.json', function () {
return done()
})
})
it('updates the locale with the new lookups provided', function () {
var i18n = y18n({
locale: 'fr',
directory: __dirname + '/locales'
})
i18n.updateLocale({
foo: 'le bar'
})
i18n.__('foo').should.equal('le bar')
})
it('loads the locale from disk prior to updating the map', function () {
fs.writeFileSync('./test/locales/fr.json', '{"meow": "le meow"}', 'utf-8')
var i18n = y18n({
locale: 'fr',
directory: __dirname + '/locales'
})
i18n.updateLocale({
foo: 'le bar'
})
i18n.__('meow').should.equal('le meow')
})
})
describe('getLocale', function () {
it('returns the configured locale', function () {
y18n().getLocale().should.equal('en')
})
})
after(function () {

@@ -203,0 +257,0 @@ rimraf.sync('./test/locales/fr.json')

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc