i18n-iso-639-1
Advanced tools
Comparing version 1.0.1 to 1.1.1
@@ -680,33 +680,2 @@ /******/ (function(modules) { // webpackBootstrap | ||
/***/ "./node_modules/webpack/buildin/harmony-module.js": | ||
/***/ (function(module, exports) { | ||
module.exports = function(originalModule) { | ||
if(!originalModule.webpackPolyfill) { | ||
var module = Object.create(originalModule); | ||
// module.parent = undefined by default | ||
if(!module.children) module.children = []; | ||
Object.defineProperty(module, "loaded", { | ||
enumerable: true, | ||
get: function() { | ||
return module.l; | ||
} | ||
}); | ||
Object.defineProperty(module, "id", { | ||
enumerable: true, | ||
get: function() { | ||
return module.i; | ||
} | ||
}); | ||
Object.defineProperty(module, "exports", { | ||
enumerable: true, | ||
}); | ||
module.webpackPolyfill = 1; | ||
} | ||
return module; | ||
}; | ||
/***/ }), | ||
/***/ "./src/data.json": | ||
@@ -724,3 +693,3 @@ /***/ (function(module, exports) { | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* WEBPACK VAR INJECTION */(function(module) {/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_keys__ = __webpack_require__("./node_modules/babel-runtime/core-js/object/keys.js"); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_keys__ = __webpack_require__("./node_modules/babel-runtime/core-js/object/keys.js"); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_keys___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_keys__); | ||
@@ -731,34 +700,29 @@ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_object_values__ = __webpack_require__("./node_modules/babel-runtime/core-js/object/values.js"); | ||
const isoCodes = __webpack_require__("./src/data.json"); | ||
module.exports = class ISO6391 { | ||
static getLanguages(codes = []) { | ||
const i18nIsoFunctions = { | ||
getLanguages: function getLanguages(codes) { | ||
return codes.map(code => ({ | ||
code, | ||
name: ISO6391.getName(code), | ||
nativeName: ISO6391.getNativeName(code) | ||
name: this.getName(code), | ||
nativeName: this.getNativeName(code) | ||
})); | ||
} | ||
static getAllNames() { | ||
}, | ||
getAllNames: function getAllNames() { | ||
return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_object_values___default()(isoCodes).map(l => l.name); | ||
} | ||
static getName(code) { | ||
return ISO6391.validate(code) ? isoCodes[code].name : ''; | ||
} | ||
static getNativeName(code) { | ||
return ISO6391.validate(code) ? isoCodes[code].nativeName : ''; | ||
} | ||
static getAllNativeNames() { | ||
}, | ||
getName: function getName(code) { | ||
return this.validate(code) ? isoCodes[code].name : ''; | ||
}, | ||
getNativeName: function getNativeName(code) { | ||
return this.validate(code) ? isoCodes[code].nativeName : ''; | ||
}, | ||
getAllNativeNames: function getAllNativeNames() { | ||
return __WEBPACK_IMPORTED_MODULE_1_babel_runtime_core_js_object_values___default()(isoCodes).map(l => l.nativeName); | ||
} | ||
static getAllCodes() { | ||
}, | ||
getAllCodes: function getAllCodes() { | ||
return __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_keys___default()(isoCodes); | ||
} | ||
static getCode(name) { | ||
}, | ||
getCode: function getCode(name) { | ||
const code = __WEBPACK_IMPORTED_MODULE_0_babel_runtime_core_js_object_keys___default()(isoCodes).find(code => { | ||
@@ -770,12 +734,12 @@ const language = isoCodes[code]; | ||
return code || ''; | ||
} | ||
static validate(code) { | ||
}, | ||
validate: function validate(code) { | ||
return isoCodes[code] !== undefined; | ||
} | ||
}; | ||
/* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__("./node_modules/webpack/buildin/harmony-module.js")(module))) | ||
exports.i18nIsoFunctions = i18nIsoFunctions; | ||
/***/ }) | ||
/******/ }); |
@@ -1,1 +0,2 @@ | ||
module.exports = require('./build/index'); | ||
const i18nIso = require('./build/index'); | ||
module.exports = i18nIso.i18nIsoFunctions; |
{ | ||
"name": "i18n-iso-639-1", | ||
"version": "1.0.1", | ||
"version": "1.1.1", | ||
"description": "JavaScript utilities for ISO-639-1 codes", | ||
"homepage": "https://github.com/sanishmaharjan/i18n-iso-639-1.git#readme", | ||
"main": "src/index.js", | ||
"main": "./index.js", | ||
"scripts": { | ||
@@ -8,0 +8,0 @@ "build": "webpack", |
@@ -0,33 +1,28 @@ | ||
'use strict'; | ||
const isoCodes = require('./data'); | ||
module.exports = class ISO6391 { | ||
static getLanguages(codes = []) { | ||
const i18nIsoFunctions = { | ||
getLanguages : function getLanguages(codes) { | ||
return codes.map(code => ({ | ||
code, | ||
name: ISO6391.getName(code), | ||
nativeName: ISO6391.getNativeName(code), | ||
name: this.getName(code), | ||
nativeName: this.getNativeName(code), | ||
})); | ||
} | ||
static getAllNames() { | ||
}, | ||
getAllNames : function getAllNames() { | ||
return Object.values(isoCodes).map(l => l.name); | ||
} | ||
static getName(code) { | ||
return ISO6391.validate(code) ? isoCodes[code].name : ''; | ||
} | ||
static getNativeName(code) { | ||
return ISO6391.validate(code) ? isoCodes[code].nativeName : ''; | ||
} | ||
static getAllNativeNames() { | ||
}, | ||
getName : function getName(code) { | ||
return this.validate(code) ? isoCodes[code].name : ''; | ||
}, | ||
getNativeName : function getNativeName(code) { | ||
return this.validate(code) ? isoCodes[code].nativeName : ''; | ||
}, | ||
getAllNativeNames : function getAllNativeNames() { | ||
return Object.values(isoCodes).map(l => l.nativeName); | ||
} | ||
static getAllCodes() { | ||
}, | ||
getAllCodes : function getAllCodes() { | ||
return Object.keys(isoCodes); | ||
} | ||
static getCode(name) { | ||
}, | ||
getCode : function getCode(name) { | ||
const code = Object.keys(isoCodes).find(code => { | ||
@@ -42,7 +37,8 @@ const language = isoCodes[code]; | ||
return code || ''; | ||
}, | ||
validate : function validate(code) { | ||
return isoCodes[code] !== undefined; | ||
} | ||
}; | ||
static validate(code) { | ||
return isoCodes[code] !== undefined; | ||
} | ||
}; | ||
exports.i18nIsoFunctions = i18nIsoFunctions; |
const assert = require('assert'); | ||
const ISO6391 = require('../src/index'); | ||
const i18nIso = require('../index'); | ||
describe('ISO6391', function() { | ||
it('Should return valid language name', function() { | ||
assert.equal(ISO6391.getName('en'), 'English'); | ||
assert.equal(ISO6391.getName('pt'), 'Portuguese'); | ||
assert.equal(ISO6391.getName('es'), 'Spanish'); | ||
assert.equal(i18nIso.getName('en'), 'English'); | ||
assert.equal(i18nIso.getName('pt'), 'Portuguese'); | ||
assert.equal(i18nIso.getName('es'), 'Spanish'); | ||
}); | ||
it('Should return valid native language Name', function() { | ||
assert.equal(ISO6391.getNativeName('en'), 'English'); | ||
assert.equal(ISO6391.getNativeName('zh'), '中文'); | ||
assert.equal(ISO6391.getNativeName('es'), 'Español'); | ||
assert.equal(i18nIso.getNativeName('en'), 'English'); | ||
assert.equal(i18nIso.getNativeName('zh'), '中文'); | ||
assert.equal(i18nIso.getNativeName('es'), 'Español'); | ||
}); | ||
it('Should return valid locale code', function() { | ||
assert.equal(ISO6391.getCode('English'), 'en'); | ||
assert.equal(ISO6391.getCode('Portuguese'), 'pt'); | ||
assert.equal(ISO6391.getCode('Spanish'), 'es'); | ||
assert.equal(ISO6391.getCode('xx'), ''); | ||
assert.equal(i18nIso.getCode('English'), 'en'); | ||
assert.equal(i18nIso.getCode('Portuguese'), 'pt'); | ||
assert.equal(i18nIso.getCode('Spanish'), 'es'); | ||
assert.equal(i18nIso.getCode('xx'), ''); | ||
}); | ||
it('Should valid locale code', function() { | ||
assert.equal(ISO6391.validate('en'), true); | ||
assert.equal(ISO6391.validate('xx'), false); | ||
assert.equal(ISO6391.validate('es'), true); | ||
assert.equal(i18nIso.validate('en'), true); | ||
assert.equal(i18nIso.validate('xx'), false); | ||
assert.equal(i18nIso.validate('es'), true); | ||
}); | ||
@@ -32,3 +32,3 @@ | ||
it('[en, zh]', function() { | ||
assert.deepEqual(ISO6391.getLanguages(['en', 'zh', 'xx']), [ | ||
assert.deepEqual(i18nIso.getLanguages(['en', 'zh', 'xx']), [ | ||
{ | ||
@@ -35,0 +35,0 @@ code: 'en', |
56186
1450