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.13 to 3.4.0

dist/runtime.d.ts

14

dist/cli.js

@@ -22,5 +22,3 @@ #!/usr/bin/env node

enumerable: true,
get: function () {
return e[k];
}
get: function () { return e[k]; }
});

@@ -30,3 +28,3 @@ }

}
n['default'] = e;
n["default"] = e;
return Object.freeze(n);

@@ -266,7 +264,7 @@ }

const { readFile, writeFile, mkdir, access } = fs__default['default'].promises;
const { readFile, writeFile, mkdir, access } = fs__default["default"].promises;
const fileExists = (path) => access(path)
.then(() => true)
.catch(() => false);
const program = sade__default['default']('svelte-i18n');
const program = sade__default["default"]('svelte-i18n');
program

@@ -280,4 +278,4 @@ .command('extract <glob> [output]')

var e_1, _a;
const filesToExtract = (await glob__default['default'](globStr)).filter((file) => file.match(/\.html|svelte$/i));
const svelteConfig = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(path.resolve(config, 'svelte.config.js'))); }).catch(() => null);
const filesToExtract = (await glob__default["default"](globStr)).filter((file) => file.match(/\.html|svelte$/i));
const svelteConfig = await (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(path.resolve(config, 'svelte.config.js')).catch(() => null);
let accumulator = {};

@@ -284,0 +282,0 @@ if (output != null && overwrite === false && (await fileExists(output))) {

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("svelte/store"),t=require("deepmerge"),n=require("intl-messageformat");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(t),i=r(n);const a={},l=(e,t,n)=>n?(t in a||(a[t]={}),e in a[t]||(a[t][e]=n),n):n,s=(e,t)=>{if(null==t)return;if(t in a&&e in a[t])return a[t][e];const n=k(t);for(let r=0;r<n.length;r++){const o=f(n[r],e);if(o)return l(e,t,o)}};let u;const c=e.writable({});function m(e){return e in u}function f(e,t){if(!m(e))return null;return function(e,t){if(null==t)return;if(t in e)return e[t];const n=t.split(".");let r=e;for(let e=0;e<n.length;e++)if("object"==typeof r){if(e>0){const t=n.slice(e,n.length).join(".");if(t in r){r=r[t];break}}r=r[n[e]]}else r=void 0;return r}(function(e){return u[e]||null}(e),t)}function d(e,...t){delete a[e],c.update((n=>(n[e]=o.default.all([n[e]||{},...t]),n)))}const g=e.derived([c],(([e])=>Object.keys(e)));c.subscribe((e=>u=e));const p={};function w(e){return p[e]}function h(e){return null!=e&&k(e).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){p[e].delete(t),0===p[e].size&&delete p[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]:Promise.resolve();const t=function(e){return k(e).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("intl-messageformat");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=o(t),i=o(n);const s={},a=(e,t,n)=>n?(t in s||(s[t]={}),e in s[t]||(s[t][e]=n),n):n,l=(e,t)=>{if(null==t)return;if(t in s&&e in s[t])return s[t][e];const n=k(t);for(let o=0;o<n.length;o++){const r=f(n[o],e);if(r)return a(e,t,r)}};let u;const c=e.writable({});function m(e){return e in u}function f(e,t){if(!m(e))return null;const n=function(e){return u[e]||null}(e);return function(e,t){if(null==t)return;if(t in e)return e[t];const n=t.split(".");let o=e;for(let e=0;e<n.length;e++)if("object"==typeof o){if(e>0){const t=n.slice(e,n.length).join(".");if(t in o){o=o[t];break}}o=o[n[e]]}else o=void 0;return o}(n,t)}function d(e,...t){delete s[e],c.update((n=>(n[e]=r.default.all([n[e]||{},...t]),n)))}const g=e.derived([c],(([e])=>Object.keys(e)));c.subscribe((e=>u=e));const p={};function h(e){return p[e]}function w(e){return null!=e&&k(e).some((e=>{var t;return null===(t=h(e))||void 0===t?void 0:t.size}))}function b(e,t){const n=Promise.all(t.map((t=>(function(e,t){p[e].delete(t),0===p[e].size&&delete p[e]}(e,t),t().then((e=>e.default||e))))));return n.then((t=>d(e,...t)))}const v={};function y(e){if(!w(e))return e in v?v[e]:Promise.resolve();const t=function(e){return k(e).map((e=>{const t=h(e);return[e,t?[...t]:[]]})).filter((([,e])=>e.length>0))}(e);return v[e]=Promise.all(t.map((([e,t])=>b(e,t)))).then((()=>{if(w(e))return y(e);delete v[e]})),v[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,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 M=e.writable(null);function $(e){return e.split("-").map(((e,t,n)=>n.slice(0,t+1).join("-"))).reverse()}function k(e,t=j().fallbackLocale){const n=$(e);return t?[...new Set([...n,...$(t)])]:n}function T(){return null!=F?F:void 0}M.subscribe((e=>{F=null!=e?e:void 0,"undefined"!=typeof window&&null!=e&&document.documentElement.setAttribute("lang",e)}));const P=Object.assign(Object.assign({},M),{set:e=>{if(e&&function(e){if(null==e)return;const t=k(e);for(let e=0;e<t.length;e++){const n=t[e];if(m(n))return n}}(e)&&h(e)){const{loadingDelay:t}=j();let n;return"undefined"!=typeof window&&null!=T()&&t?n=window.setTimeout((()=>L.set(!0)),t):L.set(!0),v(e).then((()=>{M.set(e)})).finally((()=>{clearTimeout(n),L.set(!1)}))}return M.set(e)}}),D=(e,t)=>{const n=e.split("&").find((e=>0===e.indexOf(`${t}=`)));return n?n.split("=").pop():null},E=(e,t)=>{const n=t.exec(e);return n&&n[1]||null},N=e=>{const t=Object.create(null);return n=>{const r=JSON.stringify(n);return r in t?t[r]:t[r]=e(n)}},S=(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.`)},A=N((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=S("number",n)),new Intl.NumberFormat(t,r)})),I=N((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=S("date",n):0===Object.keys(r).length&&(r=S("date","short")),new Intl.DateTimeFormat(t,r)})),q=N((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=S("time",n):0===Object.keys(r).length&&(r=S("time","short")),new Intl.DateTimeFormat(t,r)})),_=(e={})=>{var{locale:t=T()}=e,n=x(e,["locale"]);return A(Object.assign({locale:t},n))},z=(e={})=>{var{locale:t=T()}=e,n=x(e,["locale"]);return I(Object.assign({locale:t},n))},H=(e={})=>{var{locale:t=T()}=e,n=x(e,["locale"]);return q(Object.assign({locale:t},n))},Z=N(((e,t=T())=>new i.default(e,t,j().formats,{ignoreTag:j().ignoreTag}))),C=(e,t={})=>{let n=t;"object"==typeof e&&(n=e,e=n.id);const{values:r,locale:o=T(),default:i}=n;if(null==o)throw new Error("[svelte-i18n] Cannot format a message without first setting the initial locale.");let a=s(e,o);if(a){if("string"!=typeof a)return console.warn(`[svelte-i18n] Message with id "${e}" must be of type "string", found: "${typeof a}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`),a}else j().warnOnMissingMessages&&console.warn(`[svelte-i18n] The message "${e}" was not found in "${k(o).join('", "')}".${h(T())?"\n\nNote: there are at least one loader still registered to this locale that wasn't executed.":""}`),a=null!=i?i:e;if(!r)return a;let l=a;try{l=Z(a,o).format(r)}catch(t){console.warn(`[svelte-i18n] Message "${e}" has syntax error:`,t.message)}return l},G=(e,t)=>H(t).format(e),J=(e,t)=>z(t).format(e),Q=(e,t)=>_(t).format(e),U=(e,t=T())=>s(e,t),B=e.derived([P,c],(()=>C)),K=e.derived([P],(()=>G)),R=e.derived([P],(()=>J)),V=e.derived([P],(()=>Q)),W=e.derived([P,c],(()=>U));exports._=B,exports.addMessages=d,exports.date=R,exports.defineMessages=function(e){return e},exports.dictionary=c,exports.format=B,exports.getDateFormatter=z,exports.getLocaleFromHash=e=>"undefined"==typeof window?null:D(window.location.hash.substr(1),e),exports.getLocaleFromHostname=e=>"undefined"==typeof window?null:E(window.location.hostname,e),exports.getLocaleFromNavigator=()=>"undefined"==typeof window?null:window.navigator.language||window.navigator.languages[0],exports.getLocaleFromPathname=e=>"undefined"==typeof window?null:E(window.location.pathname,e),exports.getLocaleFromQueryString=e=>"undefined"==typeof window?null:D(window.location.search.substr(1),e),exports.getMessageFormatter=Z,exports.getNumberFormatter=_,exports.getTimeFormatter=H,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)),P.set(r)},exports.isLoading=L,exports.json=W,exports.locale=P,exports.locales=g,exports.number=V,exports.register=function(e,t){w(e)||function(e){p[e]=new Set}(e);const n=w(e);w(e).has(t)||(m(e)||c.update((t=>(t[e]={},t))),n.add(t))},exports.t=B,exports.time=K,exports.waitLocale=function(e){return v(e||T()||j().initialLocale)};
function x(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function O({locale:e,id:t}){console.warn(`[svelte-i18n] The message "${t}" was not found in "${k(e).join('", "')}".${w(P())?"\n\nNote: there are at least one loader still registered to this locale that wasn't executed.":""}`)}const j={fallbackLocale: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,handleMissingMessage:void 0,ignoreTag:!0};function M(){return j}const L=e.writable(!1);let F;const T=e.writable(null);function $(e){return e.split("-").map(((e,t,n)=>n.slice(0,t+1).join("-"))).reverse()}function k(e,t=M().fallbackLocale){const n=$(e);return t?[...new Set([...n,...$(t)])]:n}function P(){return null!=F?F:void 0}T.subscribe((e=>{F=null!=e?e:void 0,"undefined"!=typeof window&&null!=e&&document.documentElement.setAttribute("lang",e)}));const D=Object.assign(Object.assign({},T),{set:e=>{if(e&&function(e){if(null==e)return;const t=k(e);for(let e=0;e<t.length;e++){const n=t[e];if(m(n))return n}}(e)&&w(e)){const{loadingDelay:t}=M();let n;return"undefined"!=typeof window&&null!=P()&&t?n=window.setTimeout((()=>L.set(!0)),t):L.set(!0),y(e).then((()=>{T.set(e)})).finally((()=>{clearTimeout(n),L.set(!1)}))}return T.set(e)}}),E=(e,t)=>{const n=e.split("&").find((e=>0===e.indexOf(`${t}=`)));return n?n.split("=").pop():null},N=(e,t)=>{const n=t.exec(e);return n&&n[1]||null},S=e=>{const t=Object.create(null);return n=>{const o=JSON.stringify(n);return o in t?t[o]:t[o]=e(n)}},A=(e,t)=>{const{formats:n}=M();if(e in n&&t in n[e])return n[e][t];throw new Error(`[svelte-i18n] Unknown "${t}" ${e} format.`)},I=S((e=>{var{locale:t,format:n}=e,o=x(e,["locale","format"]);if(null==t)throw new Error('[svelte-i18n] A "locale" must be set to format numbers');return n&&(o=A("number",n)),new Intl.NumberFormat(t,o)})),q=S((e=>{var{locale:t,format:n}=e,o=x(e,["locale","format"]);if(null==t)throw new Error('[svelte-i18n] A "locale" must be set to format dates');return n?o=A("date",n):0===Object.keys(o).length&&(o=A("date","short")),new Intl.DateTimeFormat(t,o)})),_=S((e=>{var{locale:t,format:n}=e,o=x(e,["locale","format"]);if(null==t)throw new Error('[svelte-i18n] A "locale" must be set to format time values');return n?o=A("time",n):0===Object.keys(o).length&&(o=A("time","short")),new Intl.DateTimeFormat(t,o)})),z=(e={})=>{var{locale:t=P()}=e,n=x(e,["locale"]);return I(Object.assign({locale:t},n))},H=(e={})=>{var{locale:t=P()}=e,n=x(e,["locale"]);return q(Object.assign({locale:t},n))},Z=(e={})=>{var{locale:t=P()}=e,n=x(e,["locale"]);return _(Object.assign({locale:t},n))},C=S(((e,t=P())=>new i.default(e,t,M().formats,{ignoreTag:M().ignoreTag}))),G=(e,t={})=>{var n,o,r,i;let s=t;"object"==typeof e&&(s=e,e=s.id);const{values:a,locale:u=P(),default:c}=s;if(null==u)throw new Error("[svelte-i18n] Cannot format a message without first setting the initial locale.");let m=l(e,u);if(m){if("string"!=typeof m)return console.warn(`[svelte-i18n] Message with id "${e}" must be of type "string", found: "${typeof m}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`),m}else m=null!==(i=null!==(r=null===(o=(n=M()).handleMissingMessage)||void 0===o?void 0:o.call(n,{locale:u,id:e,defaultValue:c}))&&void 0!==r?r:c)&&void 0!==i?i:e;if(!a)return m;let f=m;try{f=C(m,u).format(a)}catch(t){console.warn(`[svelte-i18n] Message "${e}" has syntax error:`,t.message)}return f},J=(e,t)=>Z(t).format(e),Q=(e,t)=>H(t).format(e),U=(e,t)=>z(t).format(e),V=(e,t=P())=>l(e,t),B=e.derived([D,c],(()=>G)),K=e.derived([D],(()=>J)),R=e.derived([D],(()=>Q)),W=e.derived([D],(()=>U)),X=e.derived([D,c],(()=>V));exports._=B,exports.addMessages=d,exports.date=R,exports.defineMessages=function(e){return e},exports.dictionary=c,exports.format=B,exports.getDateFormatter=H,exports.getLocaleFromHash=e=>"undefined"==typeof window?null:E(window.location.hash.substr(1),e),exports.getLocaleFromHostname=e=>"undefined"==typeof window?null:N(window.location.hostname,e),exports.getLocaleFromNavigator=()=>"undefined"==typeof window?null:window.navigator.language||window.navigator.languages[0],exports.getLocaleFromPathname=e=>"undefined"==typeof window?null:N(window.location.pathname,e),exports.getLocaleFromQueryString=e=>"undefined"==typeof window?null:E(window.location.search.substr(1),e),exports.getMessageFormatter=C,exports.getNumberFormatter=z,exports.getTimeFormatter=Z,exports.init=function(e){const{formats:t}=e,n=x(e,["formats"]),o=e.initialLocale||e.fallbackLocale;return n.warnOnMissingMessages&&(delete n.warnOnMissingMessages,null==n.handleMissingMessage?n.handleMissingMessage=O:console.warn('[svelte-i18n] The "warnOnMissingMessages" option is deprecated. Please use the "handleMissingMessage" option instead.')),Object.assign(j,n,{initialLocale:o}),t&&("number"in t&&Object.assign(j.formats.number,t.number),"date"in t&&Object.assign(j.formats.date,t.date),"time"in t&&Object.assign(j.formats.time,t.time)),D.set(o)},exports.isLoading=L,exports.json=X,exports.locale=D,exports.locales=g,exports.number=W,exports.register=function(e,t){h(e)||function(e){p[e]=new Set}(e);const n=h(e);h(e).has(t)||(m(e)||c.update((t=>(t[e]={},t))),n.add(t))},exports.t=B,exports.time=K,exports.waitLocale=function(e){return y(e||P()||M().initialLocale)};

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

import{writable as e,derived as n}from"svelte/store";import t from"deepmerge";import o from"intl-messageformat";const r={},i=(e,n,t)=>t?(n in r||(r[n]={}),e in r[n]||(r[n][e]=t),t):t,l=(e,n)=>{if(null==n)return;if(n in r&&e in r[n])return r[n][e];const t=E(n);for(let o=0;o<t.length;o++){const r=c(t[o],e);if(r)return i(e,n,r)}};let a;const s=e({});function u(e){return e in a}function c(e,n){if(!u(e))return null;return function(e,n){if(null==n)return;if(n in e)return e[n];const t=n.split(".");let o=e;for(let e=0;e<t.length;e++)if("object"==typeof o){if(e>0){const n=t.slice(e,t.length).join(".");if(n in o){o=o[n];break}}o=o[t[e]]}else o=void 0;return o}(function(e){return a[e]||null}(e),n)}function m(e,...n){delete r[e],s.update((o=>(o[e]=t.all([o[e]||{},...n]),o)))}const f=n([s],(([e])=>Object.keys(e)));s.subscribe((e=>a=e));const d={};function g(e){return d[e]}function w(e){return null!=e&&E(e).some((e=>{var n;return null===(n=g(e))||void 0===n?void 0:n.size}))}function h(e,n){return Promise.all(n.map((n=>(function(e,n){d[e].delete(n),0===d[e].size&&delete d[e]}(e,n),n().then((e=>e.default||e)))))).then((n=>m(e,...n)))}const p={};function b(e){if(!w(e))return e in p?p[e]:Promise.resolve();const n=function(e){return E(e).map((e=>{const n=g(e);return[e,n?[...n]:[]]})).filter((([,e])=>e.length>0))}(e);return p[e]=Promise.all(n.map((([e,n])=>h(e,n)))).then((()=>{if(w(e))return b(e);delete p[e]})),p[e]}function y(e,n){g(e)||function(e){d[e]=new Set}(e);const t=g(e);g(e).has(n)||(u(e)||s.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"intl-messageformat";const r={},i=(e,n,t)=>t?(n in r||(r[n]={}),e in r[n]||(r[n][e]=t),t):t,l=(e,n)=>{if(null==n)return;if(n in r&&e in r[n])return r[n][e];const t=E(n);for(let o=0;o<t.length;o++){const r=c(t[o],e);if(r)return i(e,n,r)}};let a;const s=e({});function u(e){return e in a}function c(e,n){if(!u(e))return null;const t=function(e){return a[e]||null}(e);return function(e,n){if(null==n)return;if(n in e)return e[n];const t=n.split(".");let o=e;for(let e=0;e<t.length;e++)if("object"==typeof o){if(e>0){const n=t.slice(e,t.length).join(".");if(n in o){o=o[n];break}}o=o[t[e]]}else o=void 0;return o}(t,n)}function m(e,...n){delete r[e],s.update((o=>(o[e]=t.all([o[e]||{},...n]),o)))}const f=n([s],(([e])=>Object.keys(e)));s.subscribe((e=>a=e));const d={};function g(e){return d[e]}function h(e){return null!=e&&E(e).some((e=>{var n;return null===(n=g(e))||void 0===n?void 0:n.size}))}function w(e,n){const t=Promise.all(n.map((n=>(function(e,n){d[e].delete(n),0===d[e].size&&delete d[e]}(e,n),n().then((e=>e.default||e))))));return t.then((n=>m(e,...n)))}const p={};function b(e){if(!h(e))return e in p?p[e]:Promise.resolve();const n=function(e){return E(e).map((e=>{const n=g(e);return[e,n?[...n]:[]]})).filter((([,e])=>e.length>0))}(e);return p[e]=Promise.all(n.map((([e,n])=>w(e,n)))).then((()=>{if(h(e))return b(e);delete p[e]})),p[e]}function y(e,n){g(e)||function(e){d[e]=new Set}(e);const t=g(e);g(e).has(n)||(u(e)||s.update((n=>(n[e]={},n))),t.add(n))}
/*! *****************************************************************************

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

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function v(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 O={fallbackLocale: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}function $(e){const{formats:n}=e,t=v(e,["formats"]),o=e.initialLocale||e.fallbackLocale;return Object.assign(O,t,{initialLocale:o}),n&&("number"in n&&Object.assign(O.formats.number,n.number),"date"in n&&Object.assign(O.formats.date,n.date),"time"in n&&Object.assign(O.formats.time,n.time)),M.set(o)}const k=e(!1);let L;const T=e(null);function x(e){return e.split("-").map(((e,n,t)=>t.slice(0,n+1).join("-"))).reverse()}function E(e,n=j().fallbackLocale){const t=x(e);return n?[...new Set([...t,...x(n)])]:t}function D(){return null!=L?L:void 0}T.subscribe((e=>{L=null!=e?e:void 0,"undefined"!=typeof window&&null!=e&&document.documentElement.setAttribute("lang",e)}));const M=Object.assign(Object.assign({},T),{set:e=>{if(e&&function(e){if(null==e)return;const n=E(e);for(let e=0;e<n.length;e++){const t=n[e];if(u(t))return t}}(e)&&w(e)){const{loadingDelay:n}=j();let t;return"undefined"!=typeof window&&null!=D()&&n?t=window.setTimeout((()=>k.set(!0)),n):k.set(!0),b(e).then((()=>{T.set(e)})).finally((()=>{clearTimeout(t),k.set(!1)}))}return T.set(e)}}),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},N=e=>"undefined"==typeof window?null:S(window.location.hostname,e),A=e=>"undefined"==typeof window?null:S(window.location.pathname,e),I=()=>"undefined"==typeof window?null:window.navigator.language||window.navigator.languages[0],F=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),Z=e=>{const n=Object.create(null);return t=>{const o=JSON.stringify(t);return o in n?n[o]:n[o]=e(t)}},C=(e,n)=>{const{formats:t}=j();if(e in t&&n in t[e])return t[e][n];throw new Error(`[svelte-i18n] Unknown "${n}" ${e} format.`)},G=Z((e=>{var{locale:n,format:t}=e,o=v(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format numbers');return t&&(o=C("number",t)),new Intl.NumberFormat(n,o)})),J=Z((e=>{var{locale:n,format:t}=e,o=v(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format dates');return t?o=C("date",t):0===Object.keys(o).length&&(o=C("date","short")),new Intl.DateTimeFormat(n,o)})),U=Z((e=>{var{locale:n,format:t}=e,o=v(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format time values');return t?o=C("time",t):0===Object.keys(o).length&&(o=C("time","short")),new Intl.DateTimeFormat(n,o)})),_=(e={})=>{var{locale:n=D()}=e,t=v(e,["locale"]);return G(Object.assign({locale:n},t))},q=(e={})=>{var{locale:n=D()}=e,t=v(e,["locale"]);return J(Object.assign({locale:n},t))},B=(e={})=>{var{locale:n=D()}=e,t=v(e,["locale"]);return U(Object.assign({locale:n},t))},H=Z(((e,n=D())=>new o(e,n,j().formats,{ignoreTag:j().ignoreTag}))),K=(e,n={})=>{let t=n;"object"==typeof e&&(t=e,e=t.id);const{values:o,locale:r=D(),default:i}=t;if(null==r)throw new Error("[svelte-i18n] Cannot format a message without first setting the initial locale.");let a=l(e,r);if(a){if("string"!=typeof a)return console.warn(`[svelte-i18n] Message with id "${e}" must be of type "string", found: "${typeof a}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`),a}else j().warnOnMissingMessages&&console.warn(`[svelte-i18n] The message "${e}" was not found in "${E(r).join('", "')}".${w(D())?"\n\nNote: there are at least one loader still registered to this locale that wasn't executed.":""}`),a=null!=i?i:e;if(!o)return a;let s=a;try{s=H(a,r).format(o)}catch(n){console.warn(`[svelte-i18n] Message "${e}" has syntax error:`,n.message)}return s},Q=(e,n)=>B(n).format(e),R=(e,n)=>q(n).format(e),V=(e,n)=>_(n).format(e),W=(e,n=D())=>l(e,n),X=n([M,s],(()=>K)),Y=n([M],(()=>Q)),ee=n([M],(()=>R)),ne=n([M],(()=>V)),te=n([M,s],(()=>W));function oe(e){return e}function re(e){return b(e||D()||j().initialLocale)}export{X as _,m as addMessages,ee as date,oe as defineMessages,s as dictionary,X as format,q as getDateFormatter,z as getLocaleFromHash,N as getLocaleFromHostname,I as getLocaleFromNavigator,A as getLocaleFromPathname,F as getLocaleFromQueryString,H as getMessageFormatter,_ as getNumberFormatter,B as getTimeFormatter,$ as init,k as isLoading,te as json,M as locale,f as locales,ne as number,y as register,X as t,Y as time,re as waitLocale};
***************************************************************************** */function v(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}function O({locale:e,id:n}){console.warn(`[svelte-i18n] The message "${n}" was not found in "${E(e).join('", "')}".${h(P())?"\n\nNote: there are at least one loader still registered to this locale that wasn't executed.":""}`)}const j={fallbackLocale: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,handleMissingMessage:void 0,ignoreTag:!0};function M(){return j}function $(e){const{formats:n}=e,t=v(e,["formats"]),o=e.initialLocale||e.fallbackLocale;return t.warnOnMissingMessages&&(delete t.warnOnMissingMessages,null==t.handleMissingMessage?t.handleMissingMessage=O:console.warn('[svelte-i18n] The "warnOnMissingMessages" option is deprecated. Please use the "handleMissingMessage" option instead.')),Object.assign(j,t,{initialLocale:o}),n&&("number"in n&&Object.assign(j.formats.number,n.number),"date"in n&&Object.assign(j.formats.date,n.date),"time"in n&&Object.assign(j.formats.time,n.time)),D.set(o)}const k=e(!1);let T;const L=e(null);function x(e){return e.split("-").map(((e,n,t)=>t.slice(0,n+1).join("-"))).reverse()}function E(e,n=M().fallbackLocale){const t=x(e);return n?[...new Set([...t,...x(n)])]:t}function P(){return null!=T?T:void 0}L.subscribe((e=>{T=null!=e?e:void 0,"undefined"!=typeof window&&null!=e&&document.documentElement.setAttribute("lang",e)}));const D=Object.assign(Object.assign({},L),{set:e=>{if(e&&function(e){if(null==e)return;const n=E(e);for(let e=0;e<n.length;e++){const t=n[e];if(u(t))return t}}(e)&&h(e)){const{loadingDelay:n}=M();let t;return"undefined"!=typeof window&&null!=P()&&n?t=window.setTimeout((()=>k.set(!0)),n):k.set(!0),b(e).then((()=>{L.set(e)})).finally((()=>{clearTimeout(t),k.set(!1)}))}return L.set(e)}}),S=(e,n)=>{const t=e.split("&").find((e=>0===e.indexOf(`${n}=`)));return t?t.split("=").pop():null},N=(e,n)=>{const t=n.exec(e);return t&&t[1]||null},A=e=>"undefined"==typeof window?null:N(window.location.hostname,e),I=e=>"undefined"==typeof window?null:N(window.location.pathname,e),F=()=>"undefined"==typeof window?null:window.navigator.language||window.navigator.languages[0],z=e=>"undefined"==typeof window?null:S(window.location.search.substr(1),e),Z=e=>"undefined"==typeof window?null:S(window.location.hash.substr(1),e),C=e=>{const n=Object.create(null);return t=>{const o=JSON.stringify(t);return o in n?n[o]:n[o]=e(t)}},G=(e,n)=>{const{formats:t}=M();if(e in t&&n in t[e])return t[e][n];throw new Error(`[svelte-i18n] Unknown "${n}" ${e} format.`)},J=C((e=>{var{locale:n,format:t}=e,o=v(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format numbers');return t&&(o=G("number",t)),new Intl.NumberFormat(n,o)})),U=C((e=>{var{locale:n,format:t}=e,o=v(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format dates');return t?o=G("date",t):0===Object.keys(o).length&&(o=G("date","short")),new Intl.DateTimeFormat(n,o)})),V=C((e=>{var{locale:n,format:t}=e,o=v(e,["locale","format"]);if(null==n)throw new Error('[svelte-i18n] A "locale" must be set to format time values');return t?o=G("time",t):0===Object.keys(o).length&&(o=G("time","short")),new Intl.DateTimeFormat(n,o)})),_=(e={})=>{var{locale:n=P()}=e,t=v(e,["locale"]);return J(Object.assign({locale:n},t))},q=(e={})=>{var{locale:n=P()}=e,t=v(e,["locale"]);return U(Object.assign({locale:n},t))},B=(e={})=>{var{locale:n=P()}=e,t=v(e,["locale"]);return V(Object.assign({locale:n},t))},H=C(((e,n=P())=>new o(e,n,M().formats,{ignoreTag:M().ignoreTag}))),K=(e,n={})=>{var t,o,r,i;let a=n;"object"==typeof e&&(a=e,e=a.id);const{values:s,locale:u=P(),default:c}=a;if(null==u)throw new Error("[svelte-i18n] Cannot format a message without first setting the initial locale.");let m=l(e,u);if(m){if("string"!=typeof m)return console.warn(`[svelte-i18n] Message with id "${e}" must be of type "string", found: "${typeof m}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.`),m}else m=null!==(i=null!==(r=null===(o=(t=M()).handleMissingMessage)||void 0===o?void 0:o.call(t,{locale:u,id:e,defaultValue:c}))&&void 0!==r?r:c)&&void 0!==i?i:e;if(!s)return m;let f=m;try{f=H(m,u).format(s)}catch(n){console.warn(`[svelte-i18n] Message "${e}" has syntax error:`,n.message)}return f},Q=(e,n)=>B(n).format(e),R=(e,n)=>q(n).format(e),W=(e,n)=>_(n).format(e),X=(e,n=P())=>l(e,n),Y=n([D,s],(()=>K)),ee=n([D],(()=>Q)),ne=n([D],(()=>R)),te=n([D],(()=>W)),oe=n([D,s],(()=>X));function re(e){return e}function ie(e){return b(e||P()||M().initialLocale)}export{Y as _,m as addMessages,ne as date,re as defineMessages,s as dictionary,Y as format,q as getDateFormatter,Z as getLocaleFromHash,A as getLocaleFromHostname,F as getLocaleFromNavigator,I as getLocaleFromPathname,z as getLocaleFromQueryString,H as getMessageFormatter,_ as getNumberFormatter,B as getTimeFormatter,$ as init,k as isLoading,oe as json,D as locale,f as locales,te as number,y as register,Y as t,ee as time,ie as waitLocale};
{
"name": "svelte-i18n",
"version": "3.3.13",
"version": "3.4.0",
"main": "dist/runtime.cjs.js",
"module": "dist/runtime.esm.js",
"types": "types/runtime/index.d.ts",
"types": "dist/runtime.d.ts",
"bin": {

@@ -25,8 +25,7 @@ "svelte-i18n": "dist/cli.js"

"scripts": {
"clean": "rm -rf dist/ types/",
"clean": "rm -rf dist/",
"build": "rollup -c",
"build:types": "tsc -p src/runtime --emitDeclarationOnly",
"dev": "rollup -c -w",
"test": "cross-env NODE_ICU_DATA=node_modules/full-icu jest",
"test:ci": "npm run test -- --silent",
"test:ci": "yarn test -- --silent",
"lint": "eslint \"{src,test}/**/*.ts\"",

@@ -36,9 +35,7 @@ "format": "prettier --loglevel silent --write \"{src,test}/**/*.ts\"",

"prebuild": "yarn clean",
"postbuild": "yarn build:types",
"version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1 && git add CHANGELOG.md",
"prepublishOnly": "npm run test && npm run build"
"prepublishOnly": "yarn test && yarn build"
},
"files": [
"dist/",
"types/"
"dist/"
],

@@ -100,2 +97,3 @@ "husky": {

"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-dts": "^4.2.0",
"rollup-plugin-terser": "^7.0.2",

@@ -102,0 +100,0 @@ "rollup-plugin-typescript2": "^0.27.2",

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