New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pluginjs/i18n

Package Overview
Dependencies
Maintainers
2
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pluginjs/i18n - npm Package Compare versions

Comparing version 0.7.13 to 0.7.14

42

dist/i18n.common.js
/*!
* @pluginjs/i18n v0.7.13 (https://pluginjs.com)
* @pluginjs/i18n v0.7.14 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited

@@ -40,12 +40,12 @@ * Released under the GPL-3.0 License.

instance() {
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
const that = this;
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var that = this;
const _options = utils.deepMerge(that.defaults, options);
var _options = utils.deepMerge(that.defaults, options);
let _locale = _options.locale;
var _locale = _options.locale;
function getMessage(key, locale) {
const translation = that.getTranslation(locale);
const message = utils.getValueByPath(translation, key);
var translation = that.getTranslation(locale);
var message = utils.getValueByPath(translation, key);
return message;

@@ -56,8 +56,8 @@ }

translate(key) {
let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _locale;
let message = getMessage(key, locale);
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _locale;
var message = getMessage(key, locale);
if (typeof message === 'undefined' && _options.fallbacks) {
const locales = locale.split('-');
var locales = locale.split('-');

@@ -69,3 +69,3 @@ if (locales.length > 1 && that.hasTranslation(locales[0])) {

if (typeof message === 'undefined') {
let fallbackLocale;
var fallbackLocale;

@@ -85,3 +85,3 @@ if (_options.fallbacks !== true && that.hasTranslation(_options.fallbacks)) {

if (typeof args[args._number] !== 'undefined') {
const _number = parseInt(args[args._number], 10);
var _number = parseInt(args[args._number], 10);

@@ -100,3 +100,3 @@ if (_number === 1) {

if (typeof message === 'string') {
const parsed = template.parse(message);
var parsed = template.parse(message);

@@ -107,11 +107,11 @@ if (!parsed) {

let key;
var _key;
for (let i = 0; i < parsed.length; i++) {
key = parsed[i];
for (var i = 0; i < parsed.length; i++) {
_key = parsed[i];
if (typeof args[key] === 'undefined') {
args[key] = _options.missingPlaceholder(key);
} else if (args[key] === null) {
args[key] = _options.nullPlaceholder(key);
if (typeof args[_key] === 'undefined') {
args[_key] = _options.missingPlaceholder(_key);
} else if (args[_key] === null) {
args[_key] = _options.nullPlaceholder(_key);
}

@@ -118,0 +118,0 @@ }

/*!
* @pluginjs/i18n v0.7.13 (https://pluginjs.com)
* @pluginjs/i18n v0.7.14 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var utils=require("@pluginjs/utils"),template=_interopDefault(require("@pluginjs/template"));class I18N{constructor(t,e){this.defaults=utils.deepMerge(I18N.defaults,t),this.translations=e||{}}hasTranslation(t){return t in this.translations}addTranslation(t,e){this.translations[t]?Object.assign(this.translations[t],e):this.translations[t]=e}getTranslation(t){return this.translations[t]?this.translations[t]:{}}instance(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this,l=utils.deepMerge(e.defaults,t);let n=l.locale;function s(t,l){const n=e.getTranslation(l);return utils.getValueByPath(n,t)}return{translate(t){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n,r=s(t,i);if(void 0===r&&l.fallbacks){const n=i.split("-");if(n.length>1&&e.hasTranslation(n[0])&&(r=s(t,n[0])),void 0===r){let n;r=s(t,n=!0!==l.fallbacks&&e.hasTranslation(l.fallbacks)?l.fallbacks:e.defaults.locale)}}if("[object Array]"===Object.prototype.toString.call(r)&&r.length>=2&&"string"==typeof a._number&&void 0!==a[a._number]){const t=parseInt(a[a._number],10);1===t?r=r[0]:t>1?r=r[1]:0===t&&r.length>=3&&(r=r[2])}if("string"==typeof r){const t=template.parse(r);if(!t)return r;let e;for(let n=0;n<t.length;n++)void 0===a[e=t[n]]?a[e]=l.missingPlaceholder(e):null===a[e]&&(a[e]=l.nullPlaceholder(e));return template.render(r,a)}return Object(r)===r?r:'[missing "'.concat(i,".").concat(t,'" translation]')},setLocale(t){n=t},getLocale:()=>n}}setTranslations(t){this.translations=t}}I18N.defaults={locale:"en",fallbacks:!0,nullPlaceholder:t=>"[missing {{".concat(t,"}} value]"),missingPlaceholder:t=>"[missing {{".concat(t,"}} value]")},module.exports=I18N;
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var utils=require("@pluginjs/utils"),template=_interopDefault(require("@pluginjs/template"));class I18N{constructor(t,a){this.defaults=utils.deepMerge(I18N.defaults,t),this.translations=a||{}}hasTranslation(t){return t in this.translations}addTranslation(t,a){this.translations[t]?Object.assign(this.translations[t],a):this.translations[t]=a}getTranslation(t){return this.translations[t]?this.translations[t]:{}}instance(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=this,e=utils.deepMerge(a.defaults,t),l=e.locale;function n(t,e){var l=a.getTranslation(e);return utils.getValueByPath(l,t)}return{translate(t){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l,i=n(t,r);if(void 0===i&&e.fallbacks){var o=r.split("-");if(o.length>1&&a.hasTranslation(o[0])&&(i=n(t,o[0])),void 0===i)i=n(t,!0!==e.fallbacks&&a.hasTranslation(e.fallbacks)?e.fallbacks:a.defaults.locale)}if("[object Array]"===Object.prototype.toString.call(i)&&i.length>=2&&"string"==typeof s._number&&void 0!==s[s._number]){var u=parseInt(s[s._number],10);1===u?i=i[0]:u>1?i=i[1]:0===u&&i.length>=3&&(i=i[2])}if("string"==typeof i){var c,f=template.parse(i);if(!f)return i;for(var h=0;h<f.length;h++)void 0===s[c=f[h]]?s[c]=e.missingPlaceholder(c):null===s[c]&&(s[c]=e.nullPlaceholder(c));return template.render(i,s)}return Object(i)===i?i:'[missing "'.concat(r,".").concat(t,'" translation]')},setLocale(t){l=t},getLocale:()=>l}}setTranslations(t){this.translations=t}}I18N.defaults={locale:"en",fallbacks:!0,nullPlaceholder:t=>"[missing {{".concat(t,"}} value]"),missingPlaceholder:t=>"[missing {{".concat(t,"}} value]")},module.exports=I18N;
/*!
* @pluginjs/i18n v0.7.13 (https://pluginjs.com)
* @pluginjs/i18n v0.7.14 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited

@@ -36,12 +36,12 @@ * Released under the GPL-3.0 License.

instance() {
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
const that = this;
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var that = this;
const _options = deepMerge(that.defaults, options);
var _options = deepMerge(that.defaults, options);
let _locale = _options.locale;
var _locale = _options.locale;
function getMessage(key, locale) {
const translation = that.getTranslation(locale);
const message = getValueByPath(translation, key);
var translation = that.getTranslation(locale);
var message = getValueByPath(translation, key);
return message;

@@ -52,8 +52,8 @@ }

translate(key) {
let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _locale;
let message = getMessage(key, locale);
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var locale = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _locale;
var message = getMessage(key, locale);
if (typeof message === 'undefined' && _options.fallbacks) {
const locales = locale.split('-');
var locales = locale.split('-');

@@ -65,3 +65,3 @@ if (locales.length > 1 && that.hasTranslation(locales[0])) {

if (typeof message === 'undefined') {
let fallbackLocale;
var fallbackLocale;

@@ -81,3 +81,3 @@ if (_options.fallbacks !== true && that.hasTranslation(_options.fallbacks)) {

if (typeof args[args._number] !== 'undefined') {
const _number = parseInt(args[args._number], 10);
var _number = parseInt(args[args._number], 10);

@@ -96,3 +96,3 @@ if (_number === 1) {

if (typeof message === 'string') {
const parsed = template.parse(message);
var parsed = template.parse(message);

@@ -103,11 +103,11 @@ if (!parsed) {

let key;
var _key;
for (let i = 0; i < parsed.length; i++) {
key = parsed[i];
for (var i = 0; i < parsed.length; i++) {
_key = parsed[i];
if (typeof args[key] === 'undefined') {
args[key] = _options.missingPlaceholder(key);
} else if (args[key] === null) {
args[key] = _options.nullPlaceholder(key);
if (typeof args[_key] === 'undefined') {
args[_key] = _options.missingPlaceholder(_key);
} else if (args[_key] === null) {
args[_key] = _options.nullPlaceholder(_key);
}

@@ -114,0 +114,0 @@ }

/*!
* @pluginjs/i18n v0.7.13 (https://pluginjs.com)
* @pluginjs/i18n v0.7.14 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
import{deepMerge as t,getValueByPath as n}from"@pluginjs/utils";import s from"@pluginjs/template";class l{constructor(n,s){this.defaults=t(l.defaults,n),this.translations=s||{}}hasTranslation(t){return t in this.translations}addTranslation(t,n){this.translations[t]?Object.assign(this.translations[t],n):this.translations[t]=n}getTranslation(t){return this.translations[t]?this.translations[t]:{}}instance(){let l=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const a=this,e=t(a.defaults,l);let i=e.locale;function o(t,s){const l=a.getTranslation(s);return n(l,t)}return{translate(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i,r=o(t,l);if(void 0===r&&e.fallbacks){const n=l.split("-");if(n.length>1&&a.hasTranslation(n[0])&&(r=o(t,n[0])),void 0===r){let n;r=o(t,n=!0!==e.fallbacks&&a.hasTranslation(e.fallbacks)?e.fallbacks:a.defaults.locale)}}if("[object Array]"===Object.prototype.toString.call(r)&&r.length>=2&&"string"==typeof n._number&&void 0!==n[n._number]){const t=parseInt(n[n._number],10);1===t?r=r[0]:t>1?r=r[1]:0===t&&r.length>=3&&(r=r[2])}if("string"==typeof r){const t=s.parse(r);if(!t)return r;let l;for(let s=0;s<t.length;s++)void 0===n[l=t[s]]?n[l]=e.missingPlaceholder(l):null===n[l]&&(n[l]=e.nullPlaceholder(l));return s.render(r,n)}return Object(r)===r?r:'[missing "'.concat(l,".").concat(t,'" translation]')},setLocale(t){i=t},getLocale:()=>i}}setTranslations(t){this.translations=t}}l.defaults={locale:"en",fallbacks:!0,nullPlaceholder:t=>"[missing {{".concat(t,"}} value]"),missingPlaceholder:t=>"[missing {{".concat(t,"}} value]")};export default l;
import{deepMerge as t,getValueByPath as a}from"@pluginjs/utils";import n from"@pluginjs/template";class s{constructor(a,n){this.defaults=t(s.defaults,a),this.translations=n||{}}hasTranslation(t){return t in this.translations}addTranslation(t,a){this.translations[t]?Object.assign(this.translations[t],a):this.translations[t]=a}getTranslation(t){return this.translations[t]?this.translations[t]:{}}instance(){var s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=this,r=t(l.defaults,s),i=r.locale;function e(t,n){var s=l.getTranslation(n);return a(s,t)}return{translate(t){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i,o=e(t,s);if(void 0===o&&r.fallbacks){var c=s.split("-");if(c.length>1&&l.hasTranslation(c[0])&&(o=e(t,c[0])),void 0===o)o=e(t,!0!==r.fallbacks&&l.hasTranslation(r.fallbacks)?r.fallbacks:l.defaults.locale)}if("[object Array]"===Object.prototype.toString.call(o)&&o.length>=2&&"string"==typeof a._number&&void 0!==a[a._number]){var u=parseInt(a[a._number],10);1===u?o=o[0]:u>1?o=o[1]:0===u&&o.length>=3&&(o=o[2])}if("string"==typeof o){var h,f=n.parse(o);if(!f)return o;for(var g=0;g<f.length;g++)void 0===a[h=f[g]]?a[h]=r.missingPlaceholder(h):null===a[h]&&(a[h]=r.nullPlaceholder(h));return n.render(o,a)}return Object(o)===o?o:'[missing "'.concat(s,".").concat(t,'" translation]')},setLocale(t){i=t},getLocale:()=>i}}setTranslations(t){this.translations=t}}s.defaults={locale:"en",fallbacks:!0,nullPlaceholder:t=>"[missing {{".concat(t,"}} value]"),missingPlaceholder:t=>"[missing {{".concat(t,"}} value]")};export default s;
/*!
* @pluginjs/i18n v0.7.13 (https://pluginjs.com)
* @pluginjs/i18n v0.7.14 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited

@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License.

/*!
* @pluginjs/i18n v0.7.13 (https://pluginjs.com)
* @pluginjs/i18n v0.7.14 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited

@@ -4,0 +4,0 @@ * Released under the GPL-3.0 License.

@@ -14,3 +14,3 @@ {

},
"version": "0.7.13",
"version": "0.7.14",
"category": "core",

@@ -37,9 +37,9 @@ "main": "dist/i18n.common.js",

"dependencies": {
"@pluginjs/template": "^0.7.13",
"@pluginjs/utils": "^0.7.13"
"@pluginjs/template": "^0.7.14",
"@pluginjs/utils": "^0.7.14"
},
"devDependencies": {
"@babel/core": "^7.4.4",
"@pluginjs/browserslist-config": "^1.2.8",
"@pluginjs/cli": "^0.7.11",
"@babel/core": "^7.5.5",
"@pluginjs/browserslist-config": "^1.2.9",
"@pluginjs/cli": "^0.7.12",
"babel-jest": "*",

@@ -70,4 +70,4 @@ "jest": "*",

],
"gitHead": "dd7e1408426c72aa61b9bcd2968c389a8be92fec",
"gitHead": "e0247ab4b5e2026b77a390619f2b96bac30609c6",
"title": "Plugin"
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc