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.4 to 0.7.5

4

dist/i18n.common.js
/*!
* @pluginjs/i18n v0.7.4 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* @pluginjs/i18n v0.7.5 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.

@@ -5,0 +5,0 @@ */

/*!
* @pluginjs/i18n v0.7.4 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* @pluginjs/i18n v0.7.5 (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 s=l.locale;function n(t,l){const s=e.getTranslation(l);return utils.getValueByPath(s,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]:s,r=n(t,i);if(void 0===r&&l.fallbacks){const s=i.split("-");if(s.length>1&&e.hasTranslation(s[0])&&(r=n(t,s[0])),void 0===r){let s;r=n(t,s=!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 s=0;s<t.length;s++)void 0===a[e=t[s]]?a[e]=l.missingPlaceholder(e):null===a[e]&&(a[e]=l.nullPlaceholder(e));return template.render(r,a)}return Object(r)===r?r:`[missing "${i}.${t}" translation]`},setLocale(t){s=t},getLocale:()=>s}}setTranslations(t){this.translations=t}}I18N.defaults={locale:"en",fallbacks:!0,nullPlaceholder:t=>`[missing {{${t}}} value]`,missingPlaceholder:t=>`[missing {{${t}}} value]`},module.exports=I18N;
/*!
* @pluginjs/i18n v0.7.4 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* @pluginjs/i18n v0.7.5 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.

@@ -5,0 +5,0 @@ */

/*!
* @pluginjs/i18n v0.7.4 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* @pluginjs/i18n v0.7.5 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
import{getValueByPath,deepMerge}from"@pluginjs/utils";import template from"@pluginjs/template";class I18N{constructor(t,e){this.defaults=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=deepMerge(e.defaults,t);let a=l.locale;function s(t,l){const a=e.getTranslation(l);return getValueByPath(a,t)}return{translate(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,r=s(t,i);if(void 0===r&&l.fallbacks){const a=i.split("-");if(a.length>1&&e.hasTranslation(a[0])&&(r=s(t,a[0])),void 0===r){let a;r=s(t,a=!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 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=template.parse(r);if(!t)return r;let e;for(let a=0;a<t.length;a++)void 0===n[e=t[a]]?n[e]=l.missingPlaceholder(e):null===n[e]&&(n[e]=l.nullPlaceholder(e));return template.render(r,n)}return Object(r)===r?r:`[missing "${i}.${t}" translation]`},setLocale(t){a=t},getLocale:()=>a}}setTranslations(t){this.translations=t}}I18N.defaults={locale:"en",fallbacks:!0,nullPlaceholder:t=>`[missing {{${t}}} value]`,missingPlaceholder:t=>`[missing {{${t}}} value]`};export default I18N;
/*!
* @pluginjs/i18n v0.7.4 (https://pluginjs.com)
* Copyright 2018 Creation Studio Limited
* @pluginjs/i18n v0.7.5 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.

@@ -5,0 +5,0 @@ */

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

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

},
"version": "0.7.4",
"version": "0.7.5",
"category": "core",

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

"dependencies": {
"@pluginjs/template": "^0.7.4",
"@pluginjs/utils": "^0.7.4"
"@pluginjs/template": "^0.7.5",
"@pluginjs/utils": "^0.7.5"
},
"devDependencies": {
"@babel/core": "^7.1.5",
"@babel/core": "^7.2.2",
"@pluginjs/browserslist-config": "^1.2.2",
"@pluginjs/cli": "^0.7.4",
"@pluginjs/cli": "^0.7.5",
"babel-jest": "*",

@@ -71,3 +71,3 @@ "jest": "*",

"title": "Plugin",
"gitHead": "15dd296725c971ec08d33abd1c655b205a52ade6"
"gitHead": "a5b515ae1dc38f5f84fb18c70c322d361050593c"
}
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