@vee-validate/i18n
Advanced tools
Comparing version 4.12.0-alpha.1 to 4.12.0
/** | ||
* vee-validate v4.12.0-alpha.1 | ||
* vee-validate v4.12.0 | ||
* (c) 2023 Abdelrahman Awad | ||
@@ -110,7 +110,4 @@ * @license MIT | ||
} | ||
let DICTIONARY; | ||
const DICTIONARY = new Dictionary('en', {}); | ||
function localize(locale, dictionary) { | ||
if (!DICTIONARY) { | ||
DICTIONARY = new Dictionary('en', {}); | ||
} | ||
const generateMessage = ctx => { | ||
@@ -117,0 +114,0 @@ return DICTIONARY.resolve(ctx); |
/** | ||
* vee-validate v4.12.0-alpha.1 | ||
* vee-validate v4.12.0 | ||
* (c) 2023 Abdelrahman Awad | ||
@@ -116,7 +116,4 @@ * @license MIT | ||
} | ||
let DICTIONARY; | ||
const DICTIONARY = new Dictionary('en', {}); | ||
function localize(locale, dictionary) { | ||
if (!DICTIONARY) { | ||
DICTIONARY = new Dictionary('en', {}); | ||
} | ||
const generateMessage = ctx => { | ||
@@ -123,0 +120,0 @@ return DICTIONARY.resolve(ctx); |
/** | ||
* vee-validate v4.12.0-alpha.1 | ||
* vee-validate v4.12.0 | ||
* (c) 2023 Abdelrahman Awad | ||
* @license MIT | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidateI18n={})}(this,(function(e){"use strict";function t(e){return"function"==typeof e}function o(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function n(e,t){return Object.keys(t).forEach((i=>{if(o(t[i]))return e[i]||(e[i]={}),void n(e[i],t[i]);e[i]=t[i]})),e}function i(e,t){return e.replace(/(\d:)?{([^}]+)}/g,(function(e,o,n){if(!o||!t.params)return n in t?t[n]:t.params&&n in t.params?t.params[n]:`{${n}}`;if(!Array.isArray(t.params))return n in t.params?t.params[n]:`{${n}}`;const i=Number(o.replace(":",""));return i in t.params?t.params[i]:`${o}{${n}}`}))}class l{constructor(e,t){this.container={},this.locale=e,this.merge(t)}resolve(e){return this.format(this.locale,e)}getLocaleDefault(e,t){var o,n,i,l,r;return(null===(i=null===(n=null===(o=this.container[e])||void 0===o?void 0:o.fields)||void 0===n?void 0:n[t])||void 0===i?void 0:i._default)||(null===(r=null===(l=this.container[e])||void 0===l?void 0:l.messages)||void 0===r?void 0:r._default)}resolveLabel(e,t,o){var n,i,l,r;return o?(null===(i=null===(n=this.container[e])||void 0===n?void 0:n.names)||void 0===i?void 0:i[o])||o:(null===(r=null===(l=this.container[e])||void 0===l?void 0:l.names)||void 0===r?void 0:r[t])||t}format(e,o){var n,l,r,a,s;let c;const{rule:u,form:d,label:f,name:v}=o,p=this.resolveLabel(e,v,f);return u?(c=(null===(r=null===(l=null===(n=this.container[e])||void 0===n?void 0:n.fields)||void 0===l?void 0:l[v])||void 0===r?void 0:r[u.name])||(null===(s=null===(a=this.container[e])||void 0===a?void 0:a.messages)||void 0===s?void 0:s[u.name]),c||(c=this.getLocaleDefault(e,v)||`${p} is not valid`),t(c)?c(o):i(c,Object.assign(Object.assign({},d),{field:p,params:u.params}))):(c=this.getLocaleDefault(e,v)||`${p} is not valid`,t(c)?c(o):i(c,Object.assign(Object.assign({},d),{field:p})))}merge(e){n(this.container,e)}}let r;function a(e,t){r||(r=new l("en",{}));const o=e=>r.resolve(e);return"string"==typeof e?(r.locale=e,t&&r.merge({[e]:t}),o):(r.merge(e),o)}e.loadLocaleFromURL=async function(e){try{const t=await fetch(e,{headers:{"content-type":"application/json"}}).then((e=>e.json()));if(!t.code)return void console.error("Could not identify locale, ensure the locale file contains `code` field");a({[t.code]:t})}catch(e){console.error("Failed to load locale ")}},e.localize=a,e.setLocale=function(e){r.locale=e}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VeeValidateI18n={})}(this,(function(e){"use strict";function t(e){return"function"==typeof e}function o(e){if(!function(e){return"object"==typeof e&&null!==e}(e)||"[object Object]"!==function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}(e))return!1;if(null===Object.getPrototypeOf(e))return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function n(e,t){return Object.keys(t).forEach((i=>{if(o(t[i]))return e[i]||(e[i]={}),void n(e[i],t[i]);e[i]=t[i]})),e}function i(e,t){return e.replace(/(\d:)?{([^}]+)}/g,(function(e,o,n){if(!o||!t.params)return n in t?t[n]:t.params&&n in t.params?t.params[n]:`{${n}}`;if(!Array.isArray(t.params))return n in t.params?t.params[n]:`{${n}}`;const i=Number(o.replace(":",""));return i in t.params?t.params[i]:`${o}{${n}}`}))}const l=new class{constructor(e,t){this.container={},this.locale=e,this.merge(t)}resolve(e){return this.format(this.locale,e)}getLocaleDefault(e,t){var o,n,i,l,r;return(null===(i=null===(n=null===(o=this.container[e])||void 0===o?void 0:o.fields)||void 0===n?void 0:n[t])||void 0===i?void 0:i._default)||(null===(r=null===(l=this.container[e])||void 0===l?void 0:l.messages)||void 0===r?void 0:r._default)}resolveLabel(e,t,o){var n,i,l,r;return o?(null===(i=null===(n=this.container[e])||void 0===n?void 0:n.names)||void 0===i?void 0:i[o])||o:(null===(r=null===(l=this.container[e])||void 0===l?void 0:l.names)||void 0===r?void 0:r[t])||t}format(e,o){var n,l,r,a,s;let c;const{rule:u,form:d,label:f,name:v}=o,p=this.resolveLabel(e,v,f);return u?(c=(null===(r=null===(l=null===(n=this.container[e])||void 0===n?void 0:n.fields)||void 0===l?void 0:l[v])||void 0===r?void 0:r[u.name])||(null===(s=null===(a=this.container[e])||void 0===a?void 0:a.messages)||void 0===s?void 0:s[u.name]),c||(c=this.getLocaleDefault(e,v)||`${p} is not valid`),t(c)?c(o):i(c,Object.assign(Object.assign({},d),{field:p,params:u.params}))):(c=this.getLocaleDefault(e,v)||`${p} is not valid`,t(c)?c(o):i(c,Object.assign(Object.assign({},d),{field:p})))}merge(e){n(this.container,e)}}("en",{});function r(e,t){const o=e=>l.resolve(e);return"string"==typeof e?(l.locale=e,t&&l.merge({[e]:t}),o):(l.merge(e),o)}e.loadLocaleFromURL=async function(e){try{const t=await fetch(e,{headers:{"content-type":"application/json"}}).then((e=>e.json()));if(!t.code)return void console.error("Could not identify locale, ensure the locale file contains `code` field");r({[t.code]:t})}catch(e){console.error("Failed to load locale ")}},e.localize=r,e.setLocale=function(e){l.locale=e}})); |
{ | ||
"name": "@vee-validate/i18n", | ||
"version": "4.12.0-alpha.1", | ||
"version": "4.12.0", | ||
"description": "Localization module for VeeValidate", | ||
@@ -5,0 +5,0 @@ "author": "Abdelrahman Awad <logaretm1@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
128523
2028