Socket
Socket
Sign inDemoInstall

svelte-i18n

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-i18n - npm Package Compare versions

Comparing version 3.3.1 to 3.3.2

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## [3.3.2](https://github.com/kaisermann/svelte-i18n/compare/v3.3.1...v3.3.2) (2021-02-11)
### Bug Fixes
* expose intl-messageformat option `ignoreTag` and default to true for backwards compatibility. ([#121](https://github.com/kaisermann/svelte-i18n/issues/121)) ([341ed7f](https://github.com/kaisermann/svelte-i18n/commit/341ed7f3633447294919e4851c9db53b72bc94c3))
## [3.3.1](https://github.com/kaisermann/svelte-i18n/compare/v3.2.7...v3.3.1) (2021-02-11)

@@ -2,0 +11,0 @@

4

dist/runtime.cjs.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("svelte/store"),t=require("deepmerge"),n=require("dlv"),r=require("intl-messageformat");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(t),a=o(n),l=o(r);let s;const u=e.writable({});function c(e){return e in s}function m(e,t){if(!c(e))return null;const n=function(e){return s[e]||null}(e);if(t in n)return n[t];return a.default(n,t)}function f(e){return null==e||c(e)?e:f(D(e))}function d(e,...t){u.update((n=>(n[e]=i.default.all([n[e]||{},...t]),n)))}const p=e.derived([u],(([e])=>Object.keys(e)));u.subscribe((e=>s=e));const g={};function w(e){return g[e]}function h(e){return E(e).reverse().some((e=>{var t;return null===(t=w(e))||void 0===t?void 0:t.size}))}function b(e,t){return Promise.all(t.map((t=>(function(e,t){g[e].delete(t),0===g[e].size&&delete g[e]}(e,t),t().then((e=>e.default||e)))))).then((t=>d(e,...t)))}const y={};function v(e){if(!h(e))return e in y?y[e]:void 0;const t=function(e){return E(e).reverse().map((e=>{const t=w(e);return[e,t?[...t]:[]]})).filter((([,e])=>e.length>0))}(e);return y[e]=Promise.all(t.map((([e,t])=>b(e,t)))).then((()=>{if(h(e))return v(e);delete y[e]})),y[e]}
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("svelte/store"),t=require("deepmerge"),n=require("dlv"),r=require("intl-messageformat");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(t),a=o(n),l=o(r);let s;const u=e.writable({});function c(e){return e in s}function m(e,t){if(!c(e))return null;const n=function(e){return s[e]||null}(e);if(t in n)return n[t];return a.default(n,t)}function f(e){return null==e||c(e)?e:f($(e))}function d(e,...t){u.update((n=>(n[e]=i.default.all([n[e]||{},...t]),n)))}const p=e.derived([u],(([e])=>Object.keys(e)));u.subscribe((e=>s=e));const g={};function w(e){return g[e]}function h(e){return D(e).reverse().some((e=>{var t;return null===(t=w(e))||void 0===t?void 0:t.size}))}function b(e,t){return Promise.all(t.map((t=>(function(e,t){g[e].delete(t),0===g[e].size&&delete g[e]}(e,t),t().then((e=>e.default||e)))))).then((t=>d(e,...t)))}const y={};function v(e){if(!h(e))return e in y?y[e]:void 0;const t=function(e){return D(e).reverse().map((e=>{const t=w(e);return[e,t?[...t]:[]]})).filter((([,e])=>e.length>0))}(e);return y[e]=Promise.all(t.map((([e,t])=>b(e,t)))).then((()=>{if(h(e))return v(e);delete y[e]})),y[e]}
/*! *****************************************************************************

@@ -16,2 +16,2 @@ Copyright (c) Microsoft Corporation.

***************************************************************************** */
function x(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}const O={fallbackLocale:null,initialLocale:null,loadingDelay:200,formats:{number:{scientific:{notation:"scientific"},engineering:{notation:"engineering"},compactLong:{notation:"compact",compactDisplay:"long"},compactShort:{notation:"compact",compactDisplay:"short"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},warnOnMissingMessages:!0};function j(){return O}const L=e.writable(!1);let F;const k=e.writable(null);function M(e,t){return 0===t.indexOf(e)&&e!==t}function $(e,t){return e===t||M(e,t)||M(t,e)}function D(e){const t=e.lastIndexOf("-");if(t>0)return e.slice(0,t);const{fallbackLocale:n}=j();return n&&!$(e,n)?n:null}function E(e){const t=e.split("-").map(((e,t,n)=>n.slice(0,t+1).join("-"))),{fallbackLocale:n}=j();return n&&!$(e,n)?t.concat(E(n)):t}function N(){return F}k.subscribe((e=>{F=e,"undefined"!=typeof window&&document.documentElement.setAttribute("lang",e)}));const P=k.set;k.set=e=>{if(f(e)&&h(e)){const{loadingDelay:t}=j();let n;return"undefined"!=typeof window&&null!=N()&&t?n=window.setTimeout((()=>L.set(!0)),t):L.set(!0),v(e).then((()=>{P(e)})).finally((()=>{clearTimeout(n),L.set(!1)}))}return P(e)},k.update=e=>P(e(F));const S=(e,t)=>{const n=e.split("&").find((e=>0===e.indexOf(`${t}=`)));return n?n.split("=").pop():null},T=(e,t)=>{const n=t.exec(e);return n&&n[1]||null},I={},q=(e,t)=>{if(null==t)return;const n=m(t,e);return n||q(e,D(t))},A=(e,t)=>{if(t in I&&e in I[t])return I[t][e];const n=q(e,t);return n?((e,t,n)=>n?(t in I||(I[t]={}),e in I[t]||(I[t][e]=n),n):n)(e,t,n):void 0},_=e=>{const t=Object.create(null);return n=>{const r=JSON.stringify(n);return r in t?t[r]:t[r]=e(n)}},z=(e,t)=>{const{formats:n}=j();if(e in n&&t in n[e])return n[e][t];throw new Error(`[svelte-i18n] Unknown "${t}" ${e} format.`)},H=_((e=>{var{locale:t,format:n}=e,r=x(e,["locale","format"]);if(null==t)throw new Error('[svelte-i18n] A "locale" must be set to format numbers');return n&&(r=z("number",n)),new Intl.NumberFormat(t,r)})),Z=_((e=>{var{locale:t,format:n}=e,r=x(e,["locale","format"]);if(null==t)throw new Error('[svelte-i18n] A "locale" must be set to format dates');return n?r=z("date",n):0===Object.keys(r).length&&(r=z("date","short")),new Intl.DateTimeFormat(t,r)})),C=_((e=>{var{locale:t,format:n}=e,r=x(e,["locale","format"]);if(null==t)throw new Error('[svelte-i18n] A "locale" must be set to format time values');return n?r=z("time",n):0===Object.keys(r).length&&(r=z("time","short")),new Intl.DateTimeFormat(t,r)})),G=(e={})=>{var{locale:t=N()}=e,n=x(e,["locale"]);return H(Object.assign({locale:t},n))},J=(e={})=>{var{locale:t=N()}=e,n=x(e,["locale"]);return Z(Object.assign({locale:t},n))},Q=(e={})=>{var{locale:t=N()}=e,n=x(e,["locale"]);return C(Object.assign({locale:t},n))},U=_(((e,t=N())=>new l.default(e,t,j().formats))),B=(e,t={})=>{"object"==typeof e&&(e=(t=e).id);const{values:n,locale:r=N(),default:o}=t;if(null==r)throw new Error("[svelte-i18n] Cannot format a message without first setting the initial locale.");let i=A(e,r);if(i){if("string"!=typeof i)return console.warn(`[svelte-i18n] Message with id "${e}" must be of type "string", found: "${typeof i}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`),i}else j().warnOnMissingMessages&&console.warn(`[svelte-i18n] The message "${e}" was not found in "${E(r).join('", "')}".${h(N())?"\n\nNote: there are at least one loader still registered to this locale that wasn't executed.":""}`),i=o||e;return n?U(i,r).format(n):i},K=(e,t)=>Q(t).format(e),R=(e,t)=>J(t).format(e),V=(e,t)=>G(t).format(e),W=(e,t=N())=>A(e,t),X=e.derived([k,u],(()=>B)),Y=e.derived([k],(()=>K)),ee=e.derived([k],(()=>R)),te=e.derived([k],(()=>V)),ne=e.derived([k,u],(()=>W));exports._=X,exports.addMessages=d,exports.date=ee,exports.defineMessages=function(e){return e},exports.dictionary=u,exports.format=X,exports.getDateFormatter=J,exports.getLocaleFromHash=e=>"undefined"==typeof window?null:S(window.location.hash.substr(1),e),exports.getLocaleFromHostname=e=>"undefined"==typeof window?null:T(window.location.hostname,e),exports.getLocaleFromNavigator=()=>"undefined"==typeof window?null:window.navigator.language||window.navigator.languages[0],exports.getLocaleFromPathname=e=>"undefined"==typeof window?null:T(window.location.pathname,e),exports.getLocaleFromQueryString=e=>"undefined"==typeof window?null:S(window.location.search.substr(1),e),exports.getMessageFormatter=U,exports.getNumberFormatter=G,exports.getTimeFormatter=Q,exports.init=function(e){const{formats:t}=e,n=x(e,["formats"]),r=e.initialLocale||e.fallbackLocale;return Object.assign(O,n,{initialLocale:r}),t&&("number"in t&&Object.assign(O.formats.number,t.number),"date"in t&&Object.assign(O.formats.date,t.date),"time"in t&&Object.assign(O.formats.time,t.time)),k.set(r)},exports.isLoading=L,exports.json=ne,exports.locale=k,exports.locales=p,exports.number=te,exports.register=function(e,t){w(e)||function(e){g[e]=new Set}(e);const n=w(e);w(e).has(t)||(c(e)||u.update((t=>(t[e]={},t))),n.add(t))},exports.t=X,exports.time=Y,exports.waitLocale=function(e){return v(e||N()||j().initialLocale)};
function x(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}const O={fallbackLocale:null,initialLocale:null,loadingDelay:200,formats:{number:{scientific:{notation:"scientific"},engineering:{notation:"engineering"},compactLong:{notation:"compact",compactDisplay:"long"},compactShort:{notation:"compact",compactDisplay:"short"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},warnOnMissingMessages:!0,ignoreTag:!0};function j(){return O}const L=e.writable(!1);let F;const k=e.writable(null);function M(e,t){return 0===t.indexOf(e)&&e!==t}function T(e,t){return e===t||M(e,t)||M(t,e)}function $(e){const t=e.lastIndexOf("-");if(t>0)return e.slice(0,t);const{fallbackLocale:n}=j();return n&&!T(e,n)?n:null}function D(e){const t=e.split("-").map(((e,t,n)=>n.slice(0,t+1).join("-"))),{fallbackLocale:n}=j();return n&&!T(e,n)?t.concat(D(n)):t}function E(){return F}k.subscribe((e=>{F=e,"undefined"!=typeof window&&document.documentElement.setAttribute("lang",e)}));const N=k.set;k.set=e=>{if(f(e)&&h(e)){const{loadingDelay:t}=j();let n;return"undefined"!=typeof window&&null!=E()&&t?n=window.setTimeout((()=>L.set(!0)),t):L.set(!0),v(e).then((()=>{N(e)})).finally((()=>{clearTimeout(n),L.set(!1)}))}return N(e)},k.update=e=>N(e(F));const P=(e,t)=>{const n=e.split("&").find((e=>0===e.indexOf(`${t}=`)));return n?n.split("=").pop():null},S=(e,t)=>{const n=t.exec(e);return n&&n[1]||null},I={},q=(e,t)=>{if(null==t)return;const n=m(t,e);return n||q(e,$(t))},A=(e,t)=>{if(t in I&&e in I[t])return I[t][e];const n=q(e,t);return n?((e,t,n)=>n?(t in I||(I[t]={}),e in I[t]||(I[t][e]=n),n):n)(e,t,n):void 0},_=e=>{const t=Object.create(null);return n=>{const r=JSON.stringify(n);return r in t?t[r]:t[r]=e(n)}},z=(e,t)=>{const{formats:n}=j();if(e in n&&t in n[e])return n[e][t];throw new Error(`[svelte-i18n] Unknown "${t}" ${e} format.`)},H=_((e=>{var{locale:t,format:n}=e,r=x(e,["locale","format"]);if(null==t)throw new Error('[svelte-i18n] A "locale" must be set to format numbers');return n&&(r=z("number",n)),new Intl.NumberFormat(t,r)})),Z=_((e=>{var{locale:t,format:n}=e,r=x(e,["locale","format"]);if(null==t)throw new Error('[svelte-i18n] A "locale" must be set to format dates');return n?r=z("date",n):0===Object.keys(r).length&&(r=z("date","short")),new Intl.DateTimeFormat(t,r)})),C=_((e=>{var{locale:t,format:n}=e,r=x(e,["locale","format"]);if(null==t)throw new Error('[svelte-i18n] A "locale" must be set to format time values');return n?r=z("time",n):0===Object.keys(r).length&&(r=z("time","short")),new Intl.DateTimeFormat(t,r)})),G=(e={})=>{var{locale:t=E()}=e,n=x(e,["locale"]);return H(Object.assign({locale:t},n))},J=(e={})=>{var{locale:t=E()}=e,n=x(e,["locale"]);return Z(Object.assign({locale:t},n))},Q=(e={})=>{var{locale:t=E()}=e,n=x(e,["locale"]);return C(Object.assign({locale:t},n))},U=_(((e,t=E())=>new l.default(e,t,j().formats,{ignoreTag:j().ignoreTag}))),B=(e,t={})=>{"object"==typeof e&&(e=(t=e).id);const{values:n,locale:r=E(),default:o}=t;if(null==r)throw new Error("[svelte-i18n] Cannot format a message without first setting the initial locale.");let i=A(e,r);if(i){if("string"!=typeof i)return console.warn(`[svelte-i18n] Message with id "${e}" must be of type "string", found: "${typeof i}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`),i}else j().warnOnMissingMessages&&console.warn(`[svelte-i18n] The message "${e}" was not found in "${D(r).join('", "')}".${h(E())?"\n\nNote: there are at least one loader still registered to this locale that wasn't executed.":""}`),i=o||e;return n?U(i,r).format(n):i},K=(e,t)=>Q(t).format(e),R=(e,t)=>J(t).format(e),V=(e,t)=>G(t).format(e),W=(e,t=E())=>A(e,t),X=e.derived([k,u],(()=>B)),Y=e.derived([k],(()=>K)),ee=e.derived([k],(()=>R)),te=e.derived([k],(()=>V)),ne=e.derived([k,u],(()=>W));exports._=X,exports.addMessages=d,exports.date=ee,exports.defineMessages=function(e){return e},exports.dictionary=u,exports.format=X,exports.getDateFormatter=J,exports.getLocaleFromHash=e=>"undefined"==typeof window?null:P(window.location.hash.substr(1),e),exports.getLocaleFromHostname=e=>"undefined"==typeof window?null:S(window.location.hostname,e),exports.getLocaleFromNavigator=()=>"undefined"==typeof window?null:window.navigator.language||window.navigator.languages[0],exports.getLocaleFromPathname=e=>"undefined"==typeof window?null:S(window.location.pathname,e),exports.getLocaleFromQueryString=e=>"undefined"==typeof window?null:P(window.location.search.substr(1),e),exports.getMessageFormatter=U,exports.getNumberFormatter=G,exports.getTimeFormatter=Q,exports.init=function(e){const{formats:t}=e,n=x(e,["formats"]),r=e.initialLocale||e.fallbackLocale;return Object.assign(O,n,{initialLocale:r}),t&&("number"in t&&Object.assign(O.formats.number,t.number),"date"in t&&Object.assign(O.formats.date,t.date),"time"in t&&Object.assign(O.formats.time,t.time)),k.set(r)},exports.isLoading=L,exports.json=ne,exports.locale=k,exports.locales=p,exports.number=te,exports.register=function(e,t){w(e)||function(e){g[e]=new Set}(e);const n=w(e);w(e).has(t)||(c(e)||u.update((t=>(t[e]={},t))),n.add(t))},exports.t=X,exports.time=Y,exports.waitLocale=function(e){return v(e||E()||j().initialLocale)};

@@ -1,2 +0,2 @@

import{writable as e,derived as n}from"svelte/store";import t from"deepmerge";import o from"dlv";import r from"intl-messageformat";let i;const a=e({});function l(e){return e in i}function s(e,n){if(!l(e))return null;const t=function(e){return i[e]||null}(e);if(n in t)return t[n];return o(t,n)}function u(e){return null==e||l(e)?e:u(D(e))}function c(e,...n){a.update((o=>(o[e]=t.all([o[e]||{},...n]),o)))}const m=n([a],(([e])=>Object.keys(e)));a.subscribe((e=>i=e));const f={};function d(e){return f[e]}function w(e){return I(e).reverse().some((e=>{var n;return null===(n=d(e))||void 0===n?void 0:n.size}))}function g(e,n){return Promise.all(n.map((n=>(function(e,n){f[e].delete(n),0===f[e].size&&delete f[e]}(e,n),n().then((e=>e.default||e)))))).then((n=>c(e,...n)))}const h={};function p(e){if(!w(e))return e in h?h[e]:void 0;const n=function(e){return I(e).reverse().map((e=>{const n=d(e);return[e,n?[...n]:[]]})).filter((([,e])=>e.length>0))}(e);return h[e]=Promise.all(n.map((([e,n])=>g(e,n)))).then((()=>{if(w(e))return p(e);delete h[e]})),h[e]}function b(e,n){d(e)||function(e){f[e]=new Set}(e);const t=d(e);d(e).has(n)||(l(e)||a.update((n=>(n[e]={},n))),t.add(n))}
import{writable as e,derived as n}from"svelte/store";import t from"deepmerge";import o from"dlv";import r from"intl-messageformat";let i;const a=e({});function l(e){return e in i}function s(e,n){if(!l(e))return null;const t=function(e){return i[e]||null}(e);if(n in t)return t[n];return o(t,n)}function u(e){return null==e||l(e)?e:u(E(e))}function c(e,...n){a.update((o=>(o[e]=t.all([o[e]||{},...n]),o)))}const m=n([a],(([e])=>Object.keys(e)));a.subscribe((e=>i=e));const f={};function d(e){return f[e]}function g(e){return D(e).reverse().some((e=>{var n;return null===(n=d(e))||void 0===n?void 0:n.size}))}function w(e,n){return Promise.all(n.map((n=>(function(e,n){f[e].delete(n),0===f[e].size&&delete f[e]}(e,n),n().then((e=>e.default||e)))))).then((n=>c(e,...n)))}const h={};function p(e){if(!g(e))return e in h?h[e]:void 0;const n=function(e){return D(e).reverse().map((e=>{const n=d(e);return[e,n?[...n]:[]]})).filter((([,e])=>e.length>0))}(e);return h[e]=Promise.all(n.map((([e,n])=>w(e,n)))).then((()=>{if(g(e))return p(e);delete h[e]})),h[e]}function b(e,n){d(e)||function(e){f[e]=new Set}(e);const t=d(e);d(e).has(n)||(l(e)||a.update((n=>(n[e]={},n))),t.add(n))}
/*! *****************************************************************************

@@ -15,2 +15,2 @@ Copyright (c) Microsoft Corporation.

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function y(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(t[o[r]]=e[o[r]])}return t}const v={fallbackLocale:null,initialLocale:null,loadingDelay:200,formats:{number:{scientific:{notation:"scientific"},engineering:{notation:"engineering"},compactLong:{notation:"compact",compactDisplay:"long"},compactShort:{notation:"compact",compactDisplay:"short"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},warnOnMissingMessages:!0};function O(){return v}function j(e){const{formats:n}=e,t=y(e,["formats"]),o=e.initialLocale||e.fallbackLocale;return Object.assign(v,t,{initialLocale:o}),n&&("number"in n&&Object.assign(v.formats.number,n.number),"date"in n&&Object.assign(v.formats.date,n.date),"time"in n&&Object.assign(v.formats.time,n.time)),$.set(o)}const L=e(!1);let k;const $=e(null);function x(e,n){return 0===n.indexOf(e)&&e!==n}function E(e,n){return e===n||x(e,n)||x(n,e)}function D(e){const n=e.lastIndexOf("-");if(n>0)return e.slice(0,n);const{fallbackLocale:t}=O();return t&&!E(e,t)?t:null}function I(e){const n=e.split("-").map(((e,n,t)=>t.slice(0,n+1).join("-"))),{fallbackLocale:t}=O();return t&&!E(e,t)?n.concat(I(t)):n}function M(){return k}$.subscribe((e=>{k=e,"undefined"!=typeof window&&document.documentElement.setAttribute("lang",e)}));const N=$.set;$.set=e=>{if(u(e)&&w(e)){const{loadingDelay:n}=O();let t;return"undefined"!=typeof window&&null!=M()&&n?t=window.setTimeout((()=>L.set(!0)),n):L.set(!0),p(e).then((()=>{N(e)})).finally((()=>{clearTimeout(t),L.set(!1)}))}return N(e)},$.update=e=>N(e(k));const P=(e,n)=>{const t=e.split("&").find((e=>0===e.indexOf(`${n}=`)));return t?t.split("=").pop():null},S=(e,n)=>{const t=n.exec(e);return t&&t[1]||null},T=e=>"undefined"==typeof window?null:S(window.location.hostname,e),A=e=>"undefined"==typeof window?null:S(window.location.pathname,e),F=()=>"undefined"==typeof window?null:window.navigator.language||window.navigator.languages[0],z=e=>"undefined"==typeof window?null:P(window.location.search.substr(1),e),Z=e=>"undefined"==typeof window?null:P(window.location.hash.substr(1),e),C={},G=(e,n)=>{if(null==n)return;const t=s(n,e);return t||G(e,D(n))},J=(e,n)=>{if(n in C&&e in C[n])return C[n][e];const t=G(e,n);return t?((e,n,t)=>t?(n in C||(C[n]={}),e in C[n]||(C[n][e]=t),t):t)(e,n,t):void 0},U=e=>{const n=Object.create(null);return t=>{const o=JSON.stringify(t);return o in n?n[o]:n[o]=e(t)}},_=(e,n)=>{const{formats:t}=O();if(e in t&&n in t[e])return t[e][n];throw new Error(`[svelte-i18n] Unknown "${n}" ${e} format.`)},q=U((e=>{var{locale:n,format:t}=e,o=y(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format numbers');return t&&(o=_("number",t)),new Intl.NumberFormat(n,o)})),B=U((e=>{var{locale:n,format:t}=e,o=y(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format dates');return t?o=_("date",t):0===Object.keys(o).length&&(o=_("date","short")),new Intl.DateTimeFormat(n,o)})),H=U((e=>{var{locale:n,format:t}=e,o=y(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format time values');return t?o=_("time",t):0===Object.keys(o).length&&(o=_("time","short")),new Intl.DateTimeFormat(n,o)})),K=(e={})=>{var{locale:n=M()}=e,t=y(e,["locale"]);return q(Object.assign({locale:n},t))},Q=(e={})=>{var{locale:n=M()}=e,t=y(e,["locale"]);return B(Object.assign({locale:n},t))},R=(e={})=>{var{locale:n=M()}=e,t=y(e,["locale"]);return H(Object.assign({locale:n},t))},V=U(((e,n=M())=>new r(e,n,O().formats))),W=(e,n={})=>{"object"==typeof e&&(e=(n=e).id);const{values:t,locale:o=M(),default:r}=n;if(null==o)throw new Error("[svelte-i18n] Cannot format a message without first setting the initial locale.");let i=J(e,o);if(i){if("string"!=typeof i)return console.warn(`[svelte-i18n] Message with id "${e}" must be of type "string", found: "${typeof i}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`),i}else O().warnOnMissingMessages&&console.warn(`[svelte-i18n] The message "${e}" was not found in "${I(o).join('", "')}".${w(M())?"\n\nNote: there are at least one loader still registered to this locale that wasn't executed.":""}`),i=r||e;return t?V(i,o).format(t):i},X=(e,n)=>R(n).format(e),Y=(e,n)=>Q(n).format(e),ee=(e,n)=>K(n).format(e),ne=(e,n=M())=>J(e,n),te=n([$,a],(()=>W)),oe=n([$],(()=>X)),re=n([$],(()=>Y)),ie=n([$],(()=>ee)),ae=n([$,a],(()=>ne));function le(e){return e}function se(e){return p(e||M()||O().initialLocale)}export{te as _,c as addMessages,re as date,le as defineMessages,a as dictionary,te as format,Q as getDateFormatter,Z as getLocaleFromHash,T as getLocaleFromHostname,F as getLocaleFromNavigator,A as getLocaleFromPathname,z as getLocaleFromQueryString,V as getMessageFormatter,K as getNumberFormatter,R as getTimeFormatter,j as init,L as isLoading,ae as json,$ as locale,m as locales,ie as number,b as register,te as t,oe as time,se as waitLocale};
***************************************************************************** */function y(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(t[o[r]]=e[o[r]])}return t}const v={fallbackLocale:null,initialLocale:null,loadingDelay:200,formats:{number:{scientific:{notation:"scientific"},engineering:{notation:"engineering"},compactLong:{notation:"compact",compactDisplay:"long"},compactShort:{notation:"compact",compactDisplay:"short"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},warnOnMissingMessages:!0,ignoreTag:!0};function O(){return v}function j(e){const{formats:n}=e,t=y(e,["formats"]),o=e.initialLocale||e.fallbackLocale;return Object.assign(v,t,{initialLocale:o}),n&&("number"in n&&Object.assign(v.formats.number,n.number),"date"in n&&Object.assign(v.formats.date,n.date),"time"in n&&Object.assign(v.formats.time,n.time)),$.set(o)}const L=e(!1);let k;const $=e(null);function x(e,n){return 0===n.indexOf(e)&&e!==n}function T(e,n){return e===n||x(e,n)||x(n,e)}function E(e){const n=e.lastIndexOf("-");if(n>0)return e.slice(0,n);const{fallbackLocale:t}=O();return t&&!T(e,t)?t:null}function D(e){const n=e.split("-").map(((e,n,t)=>t.slice(0,n+1).join("-"))),{fallbackLocale:t}=O();return t&&!T(e,t)?n.concat(D(t)):n}function I(){return k}$.subscribe((e=>{k=e,"undefined"!=typeof window&&document.documentElement.setAttribute("lang",e)}));const M=$.set;$.set=e=>{if(u(e)&&g(e)){const{loadingDelay:n}=O();let t;return"undefined"!=typeof window&&null!=I()&&n?t=window.setTimeout((()=>L.set(!0)),n):L.set(!0),p(e).then((()=>{M(e)})).finally((()=>{clearTimeout(t),L.set(!1)}))}return M(e)},$.update=e=>M(e(k));const N=(e,n)=>{const t=e.split("&").find((e=>0===e.indexOf(`${n}=`)));return t?t.split("=").pop():null},P=(e,n)=>{const t=n.exec(e);return t&&t[1]||null},S=e=>"undefined"==typeof window?null:P(window.location.hostname,e),A=e=>"undefined"==typeof window?null:P(window.location.pathname,e),F=()=>"undefined"==typeof window?null:window.navigator.language||window.navigator.languages[0],z=e=>"undefined"==typeof window?null:N(window.location.search.substr(1),e),Z=e=>"undefined"==typeof window?null:N(window.location.hash.substr(1),e),C={},G=(e,n)=>{if(null==n)return;const t=s(n,e);return t||G(e,E(n))},J=(e,n)=>{if(n in C&&e in C[n])return C[n][e];const t=G(e,n);return t?((e,n,t)=>t?(n in C||(C[n]={}),e in C[n]||(C[n][e]=t),t):t)(e,n,t):void 0},U=e=>{const n=Object.create(null);return t=>{const o=JSON.stringify(t);return o in n?n[o]:n[o]=e(t)}},_=(e,n)=>{const{formats:t}=O();if(e in t&&n in t[e])return t[e][n];throw new Error(`[svelte-i18n] Unknown "${n}" ${e} format.`)},q=U((e=>{var{locale:n,format:t}=e,o=y(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format numbers');return t&&(o=_("number",t)),new Intl.NumberFormat(n,o)})),B=U((e=>{var{locale:n,format:t}=e,o=y(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format dates');return t?o=_("date",t):0===Object.keys(o).length&&(o=_("date","short")),new Intl.DateTimeFormat(n,o)})),H=U((e=>{var{locale:n,format:t}=e,o=y(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format time values');return t?o=_("time",t):0===Object.keys(o).length&&(o=_("time","short")),new Intl.DateTimeFormat(n,o)})),K=(e={})=>{var{locale:n=I()}=e,t=y(e,["locale"]);return q(Object.assign({locale:n},t))},Q=(e={})=>{var{locale:n=I()}=e,t=y(e,["locale"]);return B(Object.assign({locale:n},t))},R=(e={})=>{var{locale:n=I()}=e,t=y(e,["locale"]);return H(Object.assign({locale:n},t))},V=U(((e,n=I())=>new r(e,n,O().formats,{ignoreTag:O().ignoreTag}))),W=(e,n={})=>{"object"==typeof e&&(e=(n=e).id);const{values:t,locale:o=I(),default:r}=n;if(null==o)throw new Error("[svelte-i18n] Cannot format a message without first setting the initial locale.");let i=J(e,o);if(i){if("string"!=typeof i)return console.warn(`[svelte-i18n] Message with id "${e}" must be of type "string", found: "${typeof i}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`),i}else O().warnOnMissingMessages&&console.warn(`[svelte-i18n] The message "${e}" was not found in "${D(o).join('", "')}".${g(I())?"\n\nNote: there are at least one loader still registered to this locale that wasn't executed.":""}`),i=r||e;return t?V(i,o).format(t):i},X=(e,n)=>R(n).format(e),Y=(e,n)=>Q(n).format(e),ee=(e,n)=>K(n).format(e),ne=(e,n=I())=>J(e,n),te=n([$,a],(()=>W)),oe=n([$],(()=>X)),re=n([$],(()=>Y)),ie=n([$],(()=>ee)),ae=n([$,a],(()=>ne));function le(e){return e}function se(e){return p(e||I()||O().initialLocale)}export{te as _,c as addMessages,re as date,le as defineMessages,a as dictionary,te as format,Q as getDateFormatter,Z as getLocaleFromHash,S as getLocaleFromHostname,F as getLocaleFromNavigator,A as getLocaleFromPathname,z as getLocaleFromQueryString,V as getMessageFormatter,K as getNumberFormatter,R as getTimeFormatter,j as init,L as isLoading,ae as json,$ as locale,m as locales,ie as number,b as register,te as t,oe as time,se as waitLocale};
{
"name": "svelte-i18n",
"version": "3.3.1",
"version": "3.3.2",
"main": "dist/runtime.cjs.js",

@@ -5,0 +5,0 @@ "module": "dist/runtime.esm.js",

@@ -37,3 +37,4 @@ import type { FormatXMLElementFn, Formats } from 'intl-messageformat';

warnOnMissingMessages?: boolean;
ignoreTag?: boolean;
}
export {};
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