@sveltekit-i18n/base 1.0.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +11 -8
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var y=Object.defineProperty,W=Object.defineProperties,D=Object.getOwnPropertyDescriptor,I=Object.getOwnPropertyDescriptors,H=Object.getOwnPropertyNames,L=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var z=(a,t,e)=>t in a?y(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,l=(a,t)=>{for(var e in t||(t={}))x.call(t,e)&&z(a,e,t[e]);if(L)for(var e of L(t))K.call(t,e)&&z(a,e,t[e]);return a},d=(a,t)=>W(a,I(t));var b=(a,t)=>{var e={};for(var s in a)x.call(a,s)&&t.indexOf(s)<0&&(e[s]=a[s]);if(a!=null&&L)for(var s of L(a))t.indexOf(s)<0&&K.call(a,s)&&(e[s]=a[s]);return e};var V=(a,t)=>{for(var e in t)y(a,e,{get:t[e],enumerable:!0})},M=(a,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of H(t))!x.call(a,r)&&r!==e&&y(a,r,{get:()=>t[r],enumerable:!(s=D(t,r))||s.enumerable});return a};var $=a=>M(y({},"__esModule",{value:!0}),a);var B={};V(B,{default:()=>R});module.exports=$(B);var n=require("svelte/store");var C=({parser:a,key:t,params:e,translations:s,locale:r,fallbackLocale:i})=>{if(!(t&&r))return console.warn("[i18n]: No translation key or locale provided. Skipping translation..."),"";let o=(s[r]||{})[t];return i&&o===void 0&&(o=(s[i]||{})[t]),a.parse(o,e,r,t)},h=(...a)=>a.length?a.filter(t=>!!t).map(t=>{let e=`${t}`.toLowerCase();try{if([e]=Intl.Collator.supportedLocalesOf(t),!e)throw new Error(`[i18n]: '${t}' is non-standard.`)}catch{console.warn(`[i18n]: Non-standard locale provided: '${t}'. Check your 'translations' and 'loaders' in i18n config...`)}return e}):[],T=(a,t)=>Object.keys(a||{}).reduce((e,s)=>{let r=a[s],i=t?`${t}.${s}`:`${s}`;return r&&typeof r=="object"?l(l({},e),T(r,i)):d(l({},e),{[i]:r})},{}),j=async a=>{try{return(await Promise.all(a.map(r=>{var i=r,{loader:e}=i,s=b(i,["loader"]);return new Promise(async o=>{let c;try{c=await e()}catch(P){console.error(`[i18n]: Failed to load translation. Verify your '${s.locale}' > '${s.key}' Loader.`),console.error(P)}o(d(l({loader:e},s),{data:c}))})}))).reduce((e,{key:s,data:r,locale:i})=>{if(!r)return e;let[o]=h(i);return d(l({},e),{[o]:T(d(l({},e[o]||{}),{[s]:r}))})},{})}catch(t){console.error(t)}return{}},k=a=>t=>{try{if(typeof t=="string")return t===a;if(typeof t=="object")return t.test(a)}catch{throw new Error("[i18n]: Invalid route config!")}return!1},N=(a,t)=>{let e=!0;try{e=Object.keys(a).filter(s=>a[s]!==void 0).every(s=>a[s]===t[s])}catch{}return e};var A=1e3*60*60*24,R=class{constructor(t){this.cachedAt=0;this.loadedKeys={};this.currentRoute=(0,n.writable)();this.config=(0,n.writable)();this.isLoading=(0,n.writable)(!1);this.promises=new Set;this.loading={subscribe:this.isLoading.subscribe,toPromise:(t,e)=>{let s=Array.from(this.promises).filter(r=>N({locale:h(t)[0],route:e},r)).map(({promise:r})=>r);return Promise.all(s)},get:()=>(0,n.get)(this.isLoading)};this.privateTranslations=(0,n.writable)({});this.translations={subscribe:this.privateTranslations.subscribe,get:()=>(0,n.get)(this.translations)};this.locales=d(l({},(0,n.derived)([this.config,this.privateTranslations],([t,e])=>{if(!t)return[];let{loaders:s=[]}=t,r=s.map(({locale:o})=>h(o)[0]),i=Object.keys(e).map(o=>h(o)[0]);return Array.from(new Set([...r,...i]))},[])),{get:()=>(0,n.get)(this.locales)});this.internalLocale=(0,n.writable)();this.loaderTrigger=(0,n.derived)([this.internalLocale,this.currentRoute],([t,e],s)=>{var r,i,o;t!==void 0&&e!==void 0&&(t!==((r=(0,n.get)(this.loaderTrigger))==null?void 0:r[0])||e!==((i=(0,n.get)(this.loaderTrigger))==null?void 0:i[1]))&&((o=(0,n.get)(this.config))!=null&&o.debug&&console.debug("[i18n]: Triggering translation load..."),s([t,e]))},[]);this.localeHelper=(0,n.writable)();this.locale={subscribe:this.localeHelper.subscribe,forceSet:this.localeHelper.set,set:this.internalLocale.set,update:this.internalLocale.update,get:()=>(0,n.get)(this.locale)};this.initialized=(0,n.derived)([this.locale,this.currentRoute,this.privateTranslations],([t,e,s],r)=>{(0,n.get)(this.initialized)||r(t!==void 0&&e!==void 0&&!!Object.keys(s).length)});this.translation=(0,n.derived)([this.privateTranslations,this.locale,this.isLoading],([t,e,s],r)=>{let i=t[e];i&&Object.keys(i).length&&!s&&r(i)},{});this.t=d(l({},(0,n.derived)([this.config,this.translation],([{parser:t,fallbackLocale:e}])=>(s,...r)=>C({parser:t,key:s,params:r,translations:this.translations.get(),locale:this.locale.get(),fallbackLocale:e}))),{get:(t,...e)=>(0,n.get)(this.t)(t,...e)});this.l=d(l({},(0,n.derived)([this.config,this.translations],([{parser:t,fallbackLocale:e},s])=>(r,i,...o)=>C({parser:t,key:i,params:o,translations:s,locale:r,fallbackLocale:e}))),{get:(t,e,...s)=>(0,n.get)(this.l)(t,e,...s)});this.getLocale=t=>{if(!t)return"";let s=this.locales.get().find(r=>r===h(t)[0])||"";return h(s)[0]||""};this.setLocale=t=>{var s;if(!t)return;let[e]=h(t);if(e!==(0,n.get)(this.internalLocale))return(s=(0,n.get)(this.config))!=null&&s.debug&&console.debug(`[i18n]: Setting '${e}' locale.`),this.internalLocale.set(e),this.loading.toPromise(t,(0,n.get)(this.currentRoute))};this.setRoute=t=>{var e;if(t!==(0,n.get)(this.currentRoute)){(e=(0,n.get)(this.config))!=null&&e.debug&&console.debug(`[i18n]: Setting '${t}' route.`),this.currentRoute.set(t);let s=(0,n.get)(this.internalLocale);return this.loading.toPromise(s,t)}};this.loadConfig=async t=>{await this.configLoader(t)};this.getTranslationProps=async(t=this.locale.get(),e=(0,n.get)(this.currentRoute))=>{let s=(0,n.get)(this.config);if(!s||!t)return[];let r=this.translations.get(),{loaders:i,fallbackLocale:o="",cache:c=A}=s||{},P=Number.isNaN(+c)?A:+c;this.cachedAt?Date.now()>P+this.cachedAt&&(s!=null&&s.debug&&console.debug("[i18n]: Refreshing cache."),this.loadedKeys={},this.cachedAt=0):(s!=null&&s.debug&&console.debug("[i18n]: Setting cache timestamp."),this.cachedAt=Date.now());let[v,S]=h(t,o),E=r[v],O=r[S],w=(i||[]).map(F=>{var u=F,{locale:g}=u,f=b(u,["locale"]);return d(l({},f),{locale:h(g)[0]})}).filter(({routes:g})=>!g||(g||[]).some(k(e))).filter(({key:g,locale:f})=>f===v&&(!E||!(this.loadedKeys[v]||[]).includes(g))||o&&f===S&&(!O||!(this.loadedKeys[S]||[]).includes(g)));if(w.length){this.isLoading.set(!0),s!=null&&s.debug&&console.debug("[i18n]: Fetching translations...");let g=await j(w);this.isLoading.set(!1);let f=Object.keys(g).reduce((u,p)=>d(l({},u),{[p]:Object.keys(g[p])}),{}),F=w.filter(({key:u,locale:p})=>(f[p]||[]).some(m=>`${m}`.startsWith(u))).reduce((u,{key:p,locale:m})=>d(l({},u),{[m]:[...u[m]||[],p]}),{});return[g,F]}return[]};this.addTranslations=(t,e)=>{var r;if(!t)return;(r=(0,n.get)(this.config))!=null&&r.debug&&console.debug("[i18n]: Adding translations...");let s=Object.keys(t||{});this.privateTranslations.update(i=>s.reduce((o,c)=>d(l({},o),{[c]:l(l({},o[c]||{}),T(t[c]))}),i)),s.forEach(i=>{let o=Object.keys(t[i]).map(c=>`${c}`.split(".")[0]);e&&(o=e[i]),this.loadedKeys[i]=Array.from(new Set([...this.loadedKeys[i]||[],...o||[]]))})};this.loader=async([t,e])=>{var r;(r=(0,n.get)(this.config))!=null&&r.debug&&console.debug("[i18n]: Adding loader promise.");let s=(async()=>{let i=await this.getTranslationProps(t,e);i.length&&this.addTranslations(...i)})();this.promises.add({locale:t,route:e,promise:s}),s.then(()=>{let i=this.getLocale(t);i&&this.locale.get()!==i&&this.locale.forceSet(i)})};this.loadTranslations=(t,e=(0,n.get)(this.currentRoute)||"")=>{if(!!t)return this.setRoute(e),this.setLocale(t),this.loading.toPromise(t,e)};t&&this.loadConfig(t),this.loaderTrigger.subscribe(this.loader),this.isLoading.subscribe(async e=>{var s;e&&this.promises.size&&(await this.loading.toPromise(),this.promises.clear(),(s=(0,n.get)(this.config))!=null&&s.debug&&console.debug("[i18n]: Loader promises have been purged."))})}async configLoader(t){if(!t)throw new Error("[i18n]: No config provided!");let c=t,{initLocale:e,fallbackLocale:s,translations:r,debug:i}=c,o=b(c,["initLocale","fallbackLocale","translations","debug"]);[e]=h(e),[s]=h(s),i&&console.debug("[i18n]: Setting config."),this.config.set(l({initLocale:e,fallbackLocale:s,translations:r,debug:i},o)),r&&this.addTranslations(r),await this.loadTranslations(e)}};0&&(module.exports={});
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ declare type ExtendedStore<T, Get = () => T, Store = Readable<T>> = Store & {
|
|
|
4
4
|
get: Get;
|
|
5
5
|
};
|
|
6
6
|
declare type LoadingStore = Readable<boolean> & {
|
|
7
|
-
toPromise: (
|
|
7
|
+
toPromise: (locale?: Config.Locale, route?: string) => Promise<void[] | void>;
|
|
8
8
|
get: () => boolean;
|
|
9
9
|
};
|
|
10
10
|
declare module DotNotation {
|
|
@@ -27,6 +27,7 @@ declare module Config {
|
|
|
27
27
|
fallbackLocale?: FallbackLocale;
|
|
28
28
|
parser: Parser.T<P>;
|
|
29
29
|
cache?: number;
|
|
30
|
+
debug?: boolean;
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
33
|
declare module Loader {
|
|
@@ -59,7 +60,7 @@ declare module Translations {
|
|
|
59
60
|
type FetchTranslations = (loaders: Loader.LoaderModule[]) => Promise<SerializedTranslations>;
|
|
60
61
|
type TranslationFunction<P extends Parser.Params = Parser.Params> = (key: string, ...restParams: P) => any;
|
|
61
62
|
type LocalTranslationFunction<P extends Parser.Params = Parser.Params> = (locale: Config.Locale, key: string, ...restParams: P) => any;
|
|
62
|
-
type Translate<P extends Parser.Params = Parser.Params>
|
|
63
|
+
type Translate = <P extends Parser.Params = Parser.Params>(props: {
|
|
63
64
|
parser: Parser.T<P>;
|
|
64
65
|
key: string;
|
|
65
66
|
params: P;
|
|
@@ -89,23 +90,25 @@ declare class I18n<ParserParams extends Parser.Params = any> {
|
|
|
89
90
|
translations: ExtendedStore<Translations.SerializedTranslations>;
|
|
90
91
|
locales: ExtendedStore<Config.Locale[]>;
|
|
91
92
|
private internalLocale;
|
|
92
|
-
locale: ExtendedStore<Config.Locale, () => Config.Locale, Writable<string>>;
|
|
93
93
|
private loaderTrigger;
|
|
94
|
+
private localeHelper;
|
|
95
|
+
locale: ExtendedStore<Config.Locale, () => Config.Locale, Writable<string>> & {
|
|
96
|
+
forceSet: any;
|
|
97
|
+
};
|
|
94
98
|
initialized: Readable<boolean>;
|
|
95
99
|
private translation;
|
|
96
|
-
private translate;
|
|
97
100
|
t: ExtendedStore<Translations.TranslationFunction<ParserParams>, Translations.TranslationFunction<ParserParams>>;
|
|
98
101
|
l: ExtendedStore<Translations.LocalTranslationFunction<ParserParams>, Translations.LocalTranslationFunction<ParserParams>>;
|
|
99
102
|
private getLocale;
|
|
100
|
-
setLocale: (locale?: string | undefined) => Promise<void
|
|
101
|
-
setRoute: (route: string) => Promise<void
|
|
103
|
+
setLocale: (locale?: string | undefined) => Promise<void | void[]> | undefined;
|
|
104
|
+
setRoute: (route: string) => Promise<void | void[]> | undefined;
|
|
102
105
|
configLoader(config: Config.T<ParserParams>): Promise<void>;
|
|
103
106
|
loadConfig: (config: Config.T<ParserParams>) => Promise<void>;
|
|
104
107
|
getTranslationProps: ($locale?: string, $route?: string) => Promise<[Translations.SerializedTranslations, Loader.IndexedKeys] | [
|
|
105
108
|
]>;
|
|
106
109
|
addTranslations: (translations?: Translations.SerializedTranslations | undefined, keys?: Loader.IndexedKeys | undefined) => void;
|
|
107
|
-
private
|
|
108
|
-
loadTranslations: (locale: Config.Locale, route?: string) => Promise<void
|
|
110
|
+
private loader;
|
|
111
|
+
loadTranslations: (locale: Config.Locale, route?: string) => Promise<void | void[]> | undefined;
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
export { Config, Loader, Parser, Translations, I18n as default };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var D=Object.defineProperty,I=Object.defineProperties;var H=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var F=(i,t,e)=>t in i?D(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,l=(i,t)=>{for(var e in t||(t={}))z.call(t,e)&&F(i,e,t[e]);if(T)for(var e of T(t))K.call(t,e)&&F(i,e,t[e]);return i},d=(i,t)=>I(i,H(t));var L=(i,t)=>{var e={};for(var s in i)z.call(i,s)&&t.indexOf(s)<0&&(e[s]=i[s]);if(i!=null&&T)for(var s of T(i))t.indexOf(s)<0&&K.call(i,s)&&(e[s]=i[s]);return e};import{derived as b,get as o,writable as m}from"svelte/store";var C=({parser:i,key:t,params:e,translations:s,locale:r,fallbackLocale:a})=>{if(!(t&&r))return console.warn("[i18n]: No translation key or locale provided. Skipping translation..."),"";let n=(s[r]||{})[t];return a&&n===void 0&&(n=(s[a]||{})[t]),i.parse(n,e,r,t)},h=(...i)=>i.length?i.filter(t=>!!t).map(t=>{let e=`${t}`.toLowerCase();try{if([e]=Intl.Collator.supportedLocalesOf(t),!e)throw new Error(`[i18n]: '${t}' is non-standard.`)}catch{console.warn(`[i18n]: Non-standard locale provided: '${t}'. Check your 'translations' and 'loaders' in i18n config...`)}return e}):[],P=(i,t)=>Object.keys(i||{}).reduce((e,s)=>{let r=i[s],a=t?`${t}.${s}`:`${s}`;return r&&typeof r=="object"?l(l({},e),P(r,a)):d(l({},e),{[a]:r})},{}),j=async i=>{try{return(await Promise.all(i.map(r=>{var a=r,{loader:e}=a,s=L(a,["loader"]);return new Promise(async n=>{let c;try{c=await e()}catch(v){console.error(`[i18n]: Failed to load translation. Verify your '${s.locale}' > '${s.key}' Loader.`),console.error(v)}n(d(l({loader:e},s),{data:c}))})}))).reduce((e,{key:s,data:r,locale:a})=>{if(!r)return e;let[n]=h(a);return d(l({},e),{[n]:P(d(l({},e[n]||{}),{[s]:r}))})},{})}catch(t){console.error(t)}return{}},k=i=>t=>{try{if(typeof t=="string")return t===i;if(typeof t=="object")return t.test(i)}catch{throw new Error("[i18n]: Invalid route config!")}return!1},N=(i,t)=>{let e=!0;try{e=Object.keys(i).filter(s=>i[s]!==void 0).every(s=>i[s]===t[s])}catch{}return e};var A=1e3*60*60*24,E=class{constructor(t){this.cachedAt=0;this.loadedKeys={};this.currentRoute=m();this.config=m();this.isLoading=m(!1);this.promises=new Set;this.loading={subscribe:this.isLoading.subscribe,toPromise:(t,e)=>{let s=Array.from(this.promises).filter(r=>N({locale:h(t)[0],route:e},r)).map(({promise:r})=>r);return Promise.all(s)},get:()=>o(this.isLoading)};this.privateTranslations=m({});this.translations={subscribe:this.privateTranslations.subscribe,get:()=>o(this.translations)};this.locales=d(l({},b([this.config,this.privateTranslations],([t,e])=>{if(!t)return[];let{loaders:s=[]}=t,r=s.map(({locale:n})=>h(n)[0]),a=Object.keys(e).map(n=>h(n)[0]);return Array.from(new Set([...r,...a]))},[])),{get:()=>o(this.locales)});this.internalLocale=m();this.loaderTrigger=b([this.internalLocale,this.currentRoute],([t,e],s)=>{var r,a,n;t!==void 0&&e!==void 0&&(t!==((r=o(this.loaderTrigger))==null?void 0:r[0])||e!==((a=o(this.loaderTrigger))==null?void 0:a[1]))&&((n=o(this.config))!=null&&n.debug&&console.debug("[i18n]: Triggering translation load..."),s([t,e]))},[]);this.localeHelper=m();this.locale={subscribe:this.localeHelper.subscribe,forceSet:this.localeHelper.set,set:this.internalLocale.set,update:this.internalLocale.update,get:()=>o(this.locale)};this.initialized=b([this.locale,this.currentRoute,this.privateTranslations],([t,e,s],r)=>{o(this.initialized)||r(t!==void 0&&e!==void 0&&!!Object.keys(s).length)});this.translation=b([this.privateTranslations,this.locale,this.isLoading],([t,e,s],r)=>{let a=t[e];a&&Object.keys(a).length&&!s&&r(a)},{});this.t=d(l({},b([this.config,this.translation],([{parser:t,fallbackLocale:e}])=>(s,...r)=>C({parser:t,key:s,params:r,translations:this.translations.get(),locale:this.locale.get(),fallbackLocale:e}))),{get:(t,...e)=>o(this.t)(t,...e)});this.l=d(l({},b([this.config,this.translations],([{parser:t,fallbackLocale:e},s])=>(r,a,...n)=>C({parser:t,key:a,params:n,translations:s,locale:r,fallbackLocale:e}))),{get:(t,e,...s)=>o(this.l)(t,e,...s)});this.getLocale=t=>{if(!t)return"";let s=this.locales.get().find(r=>r===h(t)[0])||"";return h(s)[0]||""};this.setLocale=t=>{var s;if(!t)return;let[e]=h(t);if(e!==o(this.internalLocale))return(s=o(this.config))!=null&&s.debug&&console.debug(`[i18n]: Setting '${e}' locale.`),this.internalLocale.set(e),this.loading.toPromise(t,o(this.currentRoute))};this.setRoute=t=>{var e;if(t!==o(this.currentRoute)){(e=o(this.config))!=null&&e.debug&&console.debug(`[i18n]: Setting '${t}' route.`),this.currentRoute.set(t);let s=o(this.internalLocale);return this.loading.toPromise(s,t)}};this.loadConfig=async t=>{await this.configLoader(t)};this.getTranslationProps=async(t=this.locale.get(),e=o(this.currentRoute))=>{let s=o(this.config);if(!s||!t)return[];let r=this.translations.get(),{loaders:a,fallbackLocale:n="",cache:c=A}=s||{},v=Number.isNaN(+c)?A:+c;this.cachedAt?Date.now()>v+this.cachedAt&&(s!=null&&s.debug&&console.debug("[i18n]: Refreshing cache."),this.loadedKeys={},this.cachedAt=0):(s!=null&&s.debug&&console.debug("[i18n]: Setting cache timestamp."),this.cachedAt=Date.now());let[S,w]=h(t,n),O=r[S],W=r[w],x=(a||[]).map(R=>{var u=R,{locale:g}=u,f=L(u,["locale"]);return d(l({},f),{locale:h(g)[0]})}).filter(({routes:g})=>!g||(g||[]).some(k(e))).filter(({key:g,locale:f})=>f===S&&(!O||!(this.loadedKeys[S]||[]).includes(g))||n&&f===w&&(!W||!(this.loadedKeys[w]||[]).includes(g)));if(x.length){this.isLoading.set(!0),s!=null&&s.debug&&console.debug("[i18n]: Fetching translations...");let g=await j(x);this.isLoading.set(!1);let f=Object.keys(g).reduce((u,p)=>d(l({},u),{[p]:Object.keys(g[p])}),{}),R=x.filter(({key:u,locale:p})=>(f[p]||[]).some(y=>`${y}`.startsWith(u))).reduce((u,{key:p,locale:y})=>d(l({},u),{[y]:[...u[y]||[],p]}),{});return[g,R]}return[]};this.addTranslations=(t,e)=>{var r;if(!t)return;(r=o(this.config))!=null&&r.debug&&console.debug("[i18n]: Adding translations...");let s=Object.keys(t||{});this.privateTranslations.update(a=>s.reduce((n,c)=>d(l({},n),{[c]:l(l({},n[c]||{}),P(t[c]))}),a)),s.forEach(a=>{let n=Object.keys(t[a]).map(c=>`${c}`.split(".")[0]);e&&(n=e[a]),this.loadedKeys[a]=Array.from(new Set([...this.loadedKeys[a]||[],...n||[]]))})};this.loader=async([t,e])=>{var r;(r=o(this.config))!=null&&r.debug&&console.debug("[i18n]: Adding loader promise.");let s=(async()=>{let a=await this.getTranslationProps(t,e);a.length&&this.addTranslations(...a)})();this.promises.add({locale:t,route:e,promise:s}),s.then(()=>{let a=this.getLocale(t);a&&this.locale.get()!==a&&this.locale.forceSet(a)})};this.loadTranslations=(t,e=o(this.currentRoute)||"")=>{if(!!t)return this.setRoute(e),this.setLocale(t),this.loading.toPromise(t,e)};t&&this.loadConfig(t),this.loaderTrigger.subscribe(this.loader),this.isLoading.subscribe(async e=>{var s;e&&this.promises.size&&(await this.loading.toPromise(),this.promises.clear(),(s=o(this.config))!=null&&s.debug&&console.debug("[i18n]: Loader promises have been purged."))})}async configLoader(t){if(!t)throw new Error("[i18n]: No config provided!");let c=t,{initLocale:e,fallbackLocale:s,translations:r,debug:a}=c,n=L(c,["initLocale","fallbackLocale","translations","debug"]);[e]=h(e),[s]=h(s),a&&console.debug("[i18n]: Setting config."),this.config.set(l({initLocale:e,fallbackLocale:s,translations:r,debug:a},n)),r&&this.addTranslations(r),await this.loadTranslations(e)}};export{E as default};
|
package/package.json
CHANGED