@ckbox/i18n 0.0.2-dev.5 → 0.0.4

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.d.ts CHANGED
@@ -41,7 +41,27 @@ interface I18nProps {
41
41
  resources?: I18nResources;
42
42
  }
43
43
 
44
- interface I18nContextShape {
44
+ declare class Plural {
45
+ lang: string;
46
+ private _rules?;
47
+ constructor(lang: string);
48
+ /**
49
+ * Checks if plural form is supported for selected language.
50
+ *
51
+ * @returns flag indicating if plural is supported
52
+ */
53
+ static isSupported: (lang: string) => boolean;
54
+ /**
55
+ * Gets plural form of the translation key.
56
+ *
57
+ * @param key main part of the translation key
58
+ * @param plural desired plural form
59
+ * @returns plural form of the translation key
60
+ */
61
+ getKey(key: string, plural: number): string;
62
+ }
63
+
64
+ interface I18nContext {
45
65
  /**
46
66
  * Switch language.
47
67
  */
@@ -58,11 +78,15 @@ interface I18nContextShape {
58
78
  * Stored translations.
59
79
  */
60
80
  resources: I18nResources;
81
+ /**
82
+ * Plural utils.
83
+ */
84
+ pluralUtils: Plural;
61
85
  }
62
86
  /**
63
87
  * Defines React context for i18n and sets defaults.
64
88
  */
65
- declare const I18nContext: React.Context<I18nContextShape>;
89
+ declare const I18nContext: React.Context<I18nContext>;
66
90
 
67
91
  /**
68
92
  * `I18nProvider` component sets i18n context for all child components.
@@ -83,18 +107,15 @@ interface Props extends I18nProps {
83
107
  */
84
108
  declare const getTranslations: (locale: string) => I18nTranslations;
85
109
 
86
- interface MsgOpts {
87
- /**
88
- * Indicates which plural to use.
89
- */
90
- plural?: number;
91
- }
92
-
93
- interface TOpts<T extends boolean> extends MsgOpts {
110
+ interface TOpts<T extends boolean> {
94
111
  /**
95
112
  * Values to interpolate message with.
96
113
  */
97
114
  values?: (string | number)[];
115
+ /**
116
+ * Indicates which plural to use.
117
+ */
118
+ plural?: number;
98
119
  /**
99
120
  * Include html tags in message.
100
121
  */
@@ -114,4 +135,4 @@ declare const useTranslation: () => {
114
135
  lang: string;
115
136
  };
116
137
 
117
- export { I18nContext, I18nContextShape, I18nProps, I18nProvider, I18nResources, I18nTranslations, getTranslations, useTranslation };
138
+ export { I18nContext, I18nProps, I18nProvider, I18nResources, I18nTranslations, getTranslations, useTranslation };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
3
3
  */
4
- const _0x968479=_0x2e8a;(function(_0x52cab8,_0x32ebe4){const _0x3c2cd9=_0x2e8a,_0x474a7f=_0x52cab8();while(!![]){try{const _0x2591b3=-parseInt(_0x3c2cd9(0x125))/0x1*(-parseInt(_0x3c2cd9(0x10b))/0x2)+parseInt(_0x3c2cd9(0x11c))/0x3+-parseInt(_0x3c2cd9(0x119))/0x4+-parseInt(_0x3c2cd9(0x106))/0x5+-parseInt(_0x3c2cd9(0x123))/0x6*(parseInt(_0x3c2cd9(0x107))/0x7)+parseInt(_0x3c2cd9(0x116))/0x8+parseInt(_0x3c2cd9(0x121))/0x9;if(_0x2591b3===_0x32ebe4)break;else _0x474a7f['push'](_0x474a7f['shift']());}catch(_0x455bae){_0x474a7f['push'](_0x474a7f['shift']());}}}(_0x42bb,0x73680));import*as _0x3a160a from'react';import{__rest}from'tslib';import{sprintf}from'sprintf-js';function _0x2e8a(_0x46ec56,_0x354288){const _0x42bbec=_0x42bb();return _0x2e8a=function(_0x2e8a7a,_0x1d12f6){_0x2e8a7a=_0x2e8a7a-0x103;let _0x1e83d2=_0x42bbec[_0x2e8a7a];return _0x1e83d2;},_0x2e8a(_0x46ec56,_0x354288);}const I18nContext=_0x3a160a[_0x968479(0x110)]({'changeLang':()=>{},'debug':![],'lang':'en','resources':{}});function reducer(_0x202c0e,_0x25d944){const _0x4e6ab8=_0x968479;switch(_0x25d944[_0x4e6ab8(0x12b)]){case'changeLang':return Object[_0x4e6ab8(0x118)](Object[_0x4e6ab8(0x118)]({},_0x202c0e),{'lang':_0x25d944['payload']});case _0x4e6ab8(0x117):return Object[_0x4e6ab8(0x118)](Object['assign']({},_0x202c0e),{'lang':_0x25d944[_0x4e6ab8(0x105)]['lang'],'resources':Object['assign'](Object[_0x4e6ab8(0x118)]({},_0x202c0e[_0x4e6ab8(0x112)]),{[_0x25d944['payload'][_0x4e6ab8(0x115)]]:_0x25d944[_0x4e6ab8(0x105)][_0x4e6ab8(0x103)]})});}}const useI18n=({debug:debug=![],loadURL:_0x5b2291,lang:_0x2336cf='en',resources:_0x1b19da={}})=>{const _0x15893a=_0x968479,[{lang:_0x414d12,resources:_0x2c96f3},_0x1c7546]=_0x3a160a[_0x15893a(0x11a)](reducer,{'lang':_0x2336cf,'resources':_0x1b19da});_0x3a160a[_0x15893a(0x108)](()=>{const _0xfcc0aa=_0x15893a;if(_0x2c96f3[_0x414d12]||!_0x5b2291)return;fetch(_0x5b2291(_0x414d12))[_0xfcc0aa(0x122)](_0x1fdf5c=>_0x1fdf5c['json']())['then'](_0x1b7e79=>{const _0x3e17ae=_0xfcc0aa;_0x1c7546({'type':_0x3e17ae(0x117),'payload':{'lang':_0x414d12,'translations':_0x1b7e79}});});},[_0x414d12,_0x5b2291,_0x2c96f3]);const _0x1ae361=_0x142377=>{const _0x305fd6=_0x15893a;_0x1c7546({'type':_0x305fd6(0x113),'payload':_0x142377});};return{'changeLang':_0x1ae361,'debug':debug,'lang':_0x414d12,'resources':_0x2c96f3};},I18nProvider=_0x28e92c=>{const _0x3cc7fd=_0x968479;var {children:_0x4a9467}=_0x28e92c,_0x3074b2=__rest(_0x28e92c,['children']);const _0x1ac786=useI18n(_0x3074b2);return _0x3a160a[_0x3cc7fd(0x10a)](I18nContext[_0x3cc7fd(0x10c)],{'value':_0x1ac786},_0x4a9467);},getTranslations=_0x270b9a=>{const _0x466fa4=_0x968479;var _0x45da93,_0x17c3f0;const _0x364607=typeof globalThis!==_0x466fa4(0x104)?globalThis:global||self;return(_0x17c3f0=(_0x45da93=_0x364607===null||_0x364607===void 0x0?void 0x0:_0x364607[_0x466fa4(0x127)])===null||_0x45da93===void 0x0?void 0x0:_0x45da93[_0x270b9a])!==null&&_0x17c3f0!==void 0x0?_0x17c3f0:{};},defaultPlural=(_0x20a7f2,_0x5239d1=0x1)=>{const _0x428b22=_0x968479;return _0x5239d1===0x1?_0x20a7f2:_0x20a7f2+_0x428b22(0x10e);},plPlural=(_0x2cc2bb,_0x569a01=0x1)=>{if(_0x569a01===0x1)return _0x2cc2bb+'_0';else{if(_0x569a01%0xa>=0x2&&_0x569a01%0xa<=0x4&&(_0x569a01%0x64<0xc||_0x569a01%0x64>0xe))return _0x2cc2bb+'_1';else return _0x569a01!=0x1&&_0x569a01%0xa>=0x0&&_0x569a01%0xa<=0x1||_0x569a01%0xa>=0x5&&_0x569a01%0xa<=0x9||_0x569a01%0x64>=0xc&&_0x569a01%0x64<=0xe?_0x2cc2bb+'_2':_0x2cc2bb+'_3';}},plurals={'default':defaultPlural,'en':defaultPlural,'pl':plPlural},getPluralKeyFn=_0x532e6c=>{const _0x4126a5=_0x968479;return plurals[_0x532e6c]?plurals[_0x532e6c]:plurals[_0x4126a5(0x126)];},TAG_REGEX=/<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,ALLOWED_TAGS=['em',_0x968479(0x120),_0x968479(0x11e)],getMsg=(_0x12a0cf,_0x4396d2,_0x456e04={},_0x3d1dd9)=>{const _0x9205e0=_0x968479;if(_0x456e04[_0x4396d2]&&(_0x3d1dd9===null||_0x3d1dd9===void 0x0?void 0x0:_0x3d1dd9[_0x9205e0(0x130)])===undefined)return{'found':!![],'msg':_0x456e04[_0x4396d2]};const _0x2ce8a8=Object[_0x9205e0(0x124)](_0x456e04)['filter'](_0x56b303=>_0x56b303[_0x9205e0(0x111)](_0x4396d2)===0x0);if(_0x2ce8a8[_0x9205e0(0x10f)]===0x0)return{'found':![],'msg':_0x4396d2};const _0x2958cc=getPluralKeyFn(_0x12a0cf)(_0x4396d2,_0x3d1dd9===null||_0x3d1dd9===void 0x0?void 0x0:_0x3d1dd9[_0x9205e0(0x130)]);return{'found':!![],'msg':_0x456e04[_0x2958cc]};},parseMsgTags=_0x594573=>{const _0x425bbd=_0x968479,_0x2f882c=[];let _0x32cef1=0x0,_0x25519f;while((_0x25519f=TAG_REGEX[_0x425bbd(0x11f)](_0x594573))!==null){const _0x2cce4a=_0x25519f[0x0],{index:_0x1cad38}=_0x25519f,_0x1075f0=_0x2cce4a[_0x425bbd(0x129)](0x1)==='/',_0x3ae038=_0x1075f0?_0x2cce4a[_0x425bbd(0x10d)](0x2,-0x1):_0x2cce4a[_0x425bbd(0x10d)](0x1,-0x1),_0xa18cca=ALLOWED_TAGS['includes'](_0x3ae038);if(!_0xa18cca)continue;const _0x3bd113=_0x594573[_0x425bbd(0x10d)](_0x32cef1,_0x1cad38);if(!_0x3bd113){_0x32cef1=_0x1cad38+_0x2cce4a[_0x425bbd(0x10f)];continue;}_0x1075f0?_0x2f882c[_0x425bbd(0x11b)]({'type':_0x425bbd(0x128),'name':_0x2cce4a[_0x425bbd(0x10d)](0x2,-0x1),'content':_0x3bd113}):_0x2f882c['push']({'type':'text','content':_0x3bd113}),_0x32cef1=_0x1cad38+_0x2cce4a[_0x425bbd(0x10f)];}return _0x32cef1<_0x594573['length']&&_0x2f882c['push']({'type':_0x425bbd(0x11d),'content':_0x594573[_0x425bbd(0x10d)](_0x32cef1)}),_0x2f882c;};function formatMsgWithTags(_0x1fc780){const _0xf29380=_0x968479,_0x5c2667=parseMsgTags(_0x1fc780),_0x220242=_0x5c2667[_0xf29380(0x12e)](({content:_0x29dc81,type:_0x25b17e,name:_0x221cca},_0x3e3612)=>{const _0xf18eb8=_0xf29380,_0x38d004=_0x25b17e!==_0xf18eb8(0x11d)&&_0x221cca?_0x221cca:_0x3a160a[_0xf18eb8(0x12d)];return _0x3a160a[_0xf18eb8(0x10a)](_0x38d004,{'key':''+_0x3e3612},_0x29dc81);});return _0x220242;}function formatMsg(_0x490f36,_0x3e8211,_0x58bbe2){const _0x26f864=sprintf(_0x490f36,..._0x3e8211!==null&&_0x3e8211!==void 0x0?_0x3e8211:[]);if(!_0x58bbe2)return _0x26f864;return formatMsgWithTags(_0x26f864);}const useTranslation=()=>{const {lang:_0x4f6662,debug:_0xba76b9,resources:_0xd3f842}=_0x3a160a['useContext'](I18nContext);function _0x49a6a7(_0x11b619,_0x2d7376){const _0x490d40=_0x2e8a,{found:_0x348cc7,msg:_0x3c1b17}=getMsg(_0x4f6662,_0x11b619,_0xd3f842[_0x4f6662],{'plural':_0x2d7376===null||_0x2d7376===void 0x0?void 0x0:_0x2d7376[_0x490d40(0x130)]});_0xba76b9&&!_0x348cc7&&console[_0x490d40(0x114)]('['+_0x4f6662+_0x490d40(0x12f)+_0x11b619+_0x490d40(0x12a));if(_0x2d7376===null||_0x2d7376===void 0x0?void 0x0:_0x2d7376[_0x490d40(0x109)])return formatMsg(_0x3c1b17,_0x2d7376===null||_0x2d7376===void 0x0?void 0x0:_0x2d7376[_0x490d40(0x12c)],!![]);return formatMsg(_0x3c1b17,_0x2d7376===null||_0x2d7376===void 0x0?void 0x0:_0x2d7376[_0x490d40(0x12c)],![]);}return{'t':_0x49a6a7,'lang':_0x4f6662};};function _0x42bb(){const _0x42cb79=['9676953VhsCSj','then','904650NmCwKE','keys','877VWoCeg','default','CKBOX_TRANSLATIONS','tag','charAt','\x27\x20is\x20missing.','type','values','Fragment','map',']:\x20Translation\x20for\x20key\x20\x27','plural','translations','undefined','payload','4104040otIaDC','35gYJwRN','useEffect','processTags','createElement','250JJLbkw','Provider','slice','_plural','length','createContext','indexOf','resources','changeLang','log','lang','2727048RrGOCV','loadTranslations','assign','1087252HUCZtz','useReducer','push','2380431ALSHMj','text','code','exec','strong'];_0x42bb=function(){return _0x42cb79;};return _0x42bb();}export{I18nContext,I18nProvider,getTranslations,useTranslation};
4
+ const _0x371d3d=_0x4b6e;(function(_0x2415f9,_0x53925d){const _0x42dc13=_0x4b6e,_0x439ac5=_0x2415f9();while(!![]){try{const _0x3a8fe7=-parseInt(_0x42dc13(0x20c))/0x1*(parseInt(_0x42dc13(0x20b))/0x2)+parseInt(_0x42dc13(0x219))/0x3+-parseInt(_0x42dc13(0x1f5))/0x4*(-parseInt(_0x42dc13(0x200))/0x5)+parseInt(_0x42dc13(0x1f9))/0x6+parseInt(_0x42dc13(0x1f1))/0x7*(-parseInt(_0x42dc13(0x1f8))/0x8)+-parseInt(_0x42dc13(0x213))/0x9+parseInt(_0x42dc13(0x1ef))/0xa*(parseInt(_0x42dc13(0x1f0))/0xb);if(_0x3a8fe7===_0x53925d)break;else _0x439ac5['push'](_0x439ac5['shift']());}catch(_0x361923){_0x439ac5['push'](_0x439ac5['shift']());}}}(_0x17a3,0xb9b89));import*as _0x1988da from'react';import{__rest}from'tslib';import{sprintf}from'sprintf-js';class Plural{constructor(_0x1ffb8a){const _0x1a75ee=_0x4b6e;this[_0x1a75ee(0x1e6)]=_0x1ffb8a;try{this[_0x1a75ee(0x201)]=new Intl['PluralRules'](_0x1ffb8a);}catch(_0x2c7e3a){console[_0x1a75ee(0x206)]('Plural\x20rules\x20could\x20not\x20be\x20created.\x20Perhaps\x20`Intl.PluralRules`\x20is\x20not\x20supported?');}}[_0x371d3d(0x1f7)](_0x4f27e5,_0x36c153){const _0x28c8d1=_0x371d3d;if(!this['_rules'])return _0x4f27e5+_0x28c8d1(0x205);const _0x383f68=this[_0x28c8d1(0x201)][_0x28c8d1(0x1eb)](_0x36c153);return _0x4f27e5+'_'+_0x383f68;}}function _0x17a3(){const _0x2ef3db=['createElement','translations','Fragment','1010cLYWzD','138259bdLKPw','84742ZozJKo','createContext','values','filter','1092340eDzgKc','tag','getKey','32IxDVQm','1843686PcLsea','keys','pluralUtils','useReducer','charAt','indexOf','log','25AJoYkC','_rules','loadTranslations','map','payload','_one','warn','length','strong','useEffect','type','113756Aueulw','26nbuZyu','json','supportedLocalesOf','children','useContext','text','\x22\x20is\x20not\x20supported.','11476863uYgaCM','isSupported','resources','\x27\x20is\x20missing.','push','exec','1862991GBCTkV','plural','assign','Plural\x20form\x20for\x20language\x20\x22','lang','then','changeLang','slice','code','select'];_0x17a3=function(){return _0x2ef3db;};return _0x17a3();}function _0x4b6e(_0x54ef0c,_0x3b0bff){const _0x17a3f1=_0x17a3();return _0x4b6e=function(_0x4b6e0a,_0x13d342){_0x4b6e0a=_0x4b6e0a-0x1e6;let _0x4962fe=_0x17a3f1[_0x4b6e0a];return _0x4962fe;},_0x4b6e(_0x54ef0c,_0x3b0bff);}Plural['isSupported']=_0x4069c0=>{const _0x181566=_0x371d3d;try{return Intl['PluralRules'][_0x181566(0x20e)]([_0x4069c0])[_0x181566(0x207)]>0x0;}catch(_0xc279c7){return![];}};const I18nContext=_0x1988da[_0x371d3d(0x1f2)]({'changeLang':()=>{},'debug':![],'lang':'en','resources':{},'pluralUtils':new Plural('en')});function reducer(_0x264c49,_0x20aa8d){const _0x454e25=_0x371d3d;switch(_0x20aa8d[_0x454e25(0x20a)]){case'changeLang':return Object['assign'](Object['assign']({},_0x264c49),{'lang':_0x20aa8d[_0x454e25(0x204)]});case'loadTranslations':return Object[_0x454e25(0x21b)](Object[_0x454e25(0x21b)]({},_0x264c49),{'lang':_0x20aa8d[_0x454e25(0x204)]['lang'],'resources':Object[_0x454e25(0x21b)](Object[_0x454e25(0x21b)]({},_0x264c49[_0x454e25(0x215)]),{[_0x20aa8d['payload'][_0x454e25(0x1e6)]]:_0x20aa8d[_0x454e25(0x204)][_0x454e25(0x1ed)]})});}}const useI18n=({debug:debug=![],loadURL:_0x4958c0,lang:_0x4ad392='en',resources:_0xc6028f={}})=>{const _0x42a46b=_0x371d3d,[{lang:_0x3317c3,resources:_0x325fa6},_0x2ec0f7]=_0x1988da[_0x42a46b(0x1fc)](reducer,{'lang':_0x4ad392,'resources':_0xc6028f});_0x1988da[_0x42a46b(0x209)](()=>{const _0x41eb4f=_0x42a46b,_0x3720eb=Plural[_0x41eb4f(0x214)](_0x3317c3);!_0x3720eb&&console[_0x41eb4f(0x206)](_0x41eb4f(0x21c)+_0x3317c3+_0x41eb4f(0x212));},[_0x3317c3]),_0x1988da[_0x42a46b(0x209)](()=>{const _0x5b225=_0x42a46b;if(_0x325fa6[_0x3317c3]||!_0x4958c0)return;fetch(_0x4958c0(_0x3317c3))[_0x5b225(0x1e7)](_0x103e33=>_0x103e33[_0x5b225(0x20d)]())[_0x5b225(0x1e7)](_0x38e967=>{const _0x3a16e4=_0x5b225;_0x2ec0f7({'type':_0x3a16e4(0x202),'payload':{'lang':_0x3317c3,'translations':_0x38e967}});});},[_0x3317c3,_0x4958c0,_0x325fa6]);const _0x4c267a=_0x2a8c61=>{const _0x95ef05=_0x42a46b;_0x2ec0f7({'type':_0x95ef05(0x1e8),'payload':_0x2a8c61});};return{'changeLang':_0x4c267a,'debug':debug,'lang':_0x3317c3,'pluralUtils':new Plural(_0x3317c3),'resources':_0x325fa6};},I18nProvider=_0x4fb8e1=>{const _0x27a025=_0x371d3d;var {children:_0x40d30f}=_0x4fb8e1,_0x1a0448=__rest(_0x4fb8e1,[_0x27a025(0x20f)]);const _0xfad24b=useI18n(_0x1a0448);return _0x1988da[_0x27a025(0x1ec)](I18nContext['Provider'],{'value':_0xfad24b},_0x40d30f);},getTranslations=_0x399d85=>{var _0x55859a,_0x4a1fc3;const _0x12a07f=typeof globalThis!=='undefined'?globalThis:global||self;return(_0x4a1fc3=(_0x55859a=_0x12a07f===null||_0x12a07f===void 0x0?void 0x0:_0x12a07f['CKBOX_TRANSLATIONS'])===null||_0x55859a===void 0x0?void 0x0:_0x55859a[_0x399d85])!==null&&_0x4a1fc3!==void 0x0?_0x4a1fc3:{};},TAG_REGEX=/<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,ALLOWED_TAGS=['em',_0x371d3d(0x208),_0x371d3d(0x1ea)],getMsg=(_0x4eeabb,_0x1448c1={},_0x12ef25)=>{const _0x4f24f5=_0x371d3d,_0xc06010=_0x12ef25[_0x4f24f5(0x21a)];if(_0x1448c1[_0x4eeabb]&&_0xc06010===undefined)return{'found':!![],'msg':_0x1448c1[_0x4eeabb]};const _0x4c5c47=Object[_0x4f24f5(0x1fa)](_0x1448c1)[_0x4f24f5(0x1f4)](_0x89e70e=>_0x89e70e[_0x4f24f5(0x1fe)](_0x4eeabb)===0x0);if(_0x4c5c47[_0x4f24f5(0x207)]===0x0||_0xc06010===undefined)return{'found':![],'msg':_0x4eeabb};const _0x244eff=_0x12ef25[_0x4f24f5(0x1fb)][_0x4f24f5(0x1f7)](_0x4eeabb,_0xc06010);return{'found':!![],'msg':_0x1448c1[_0x244eff]};},parseMsgTags=_0x3aa284=>{const _0x2e8490=_0x371d3d,_0x43e0b5=[];let _0x991d64=0x0,_0xa888ef;while((_0xa888ef=TAG_REGEX[_0x2e8490(0x218)](_0x3aa284))!==null){const _0x4d6de2=_0xa888ef[0x0],{index:_0x37fb1a}=_0xa888ef,_0x19bd17=_0x4d6de2[_0x2e8490(0x1fd)](0x1)==='/',_0x2d9f66=_0x19bd17?_0x4d6de2[_0x2e8490(0x1e9)](0x2,-0x1):_0x4d6de2[_0x2e8490(0x1e9)](0x1,-0x1),_0x29dfbf=ALLOWED_TAGS['includes'](_0x2d9f66);if(!_0x29dfbf)continue;const _0x317fe7=_0x3aa284['slice'](_0x991d64,_0x37fb1a);if(!_0x317fe7){_0x991d64=_0x37fb1a+_0x4d6de2[_0x2e8490(0x207)];continue;}_0x19bd17?_0x43e0b5[_0x2e8490(0x217)]({'type':_0x2e8490(0x1f6),'name':_0x4d6de2[_0x2e8490(0x1e9)](0x2,-0x1),'content':_0x317fe7}):_0x43e0b5['push']({'type':'text','content':_0x317fe7}),_0x991d64=_0x37fb1a+_0x4d6de2[_0x2e8490(0x207)];}return _0x991d64<_0x3aa284[_0x2e8490(0x207)]&&_0x43e0b5['push']({'type':_0x2e8490(0x211),'content':_0x3aa284[_0x2e8490(0x1e9)](_0x991d64)}),_0x43e0b5;};function formatMsgWithTags(_0x4d65bf){const _0x10e4e6=_0x371d3d,_0x681299=parseMsgTags(_0x4d65bf),_0x423893=_0x681299[_0x10e4e6(0x203)](({content:_0x3254ab,type:_0x5b8425,name:_0x56fe0a},_0x584dd3)=>{const _0xd8d63=_0x10e4e6,_0x5340=_0x5b8425!==_0xd8d63(0x211)&&_0x56fe0a?_0x56fe0a:_0x1988da[_0xd8d63(0x1ee)];return _0x1988da['createElement'](_0x5340,{'key':''+_0x584dd3},_0x3254ab);});return _0x423893;}function formatMsg(_0x12b0cc,_0x2752db,_0x171371){const _0x476836=sprintf(_0x12b0cc,..._0x2752db!==null&&_0x2752db!==void 0x0?_0x2752db:[]);if(!_0x171371)return _0x476836;return formatMsgWithTags(_0x476836);}const useTranslation=()=>{const _0x42d45b=_0x371d3d,{lang:_0x44d07,debug:_0x2759e1,pluralUtils:_0x197ffc,resources:_0x5bda38}=_0x1988da[_0x42d45b(0x210)](I18nContext);function _0x38fd66(_0x350b06,_0x2a6c4a){const _0x2715c4=_0x42d45b,{found:_0x37a9f3,msg:_0x2fbecc}=getMsg(_0x350b06,_0x5bda38[_0x44d07],{'plural':_0x2a6c4a===null||_0x2a6c4a===void 0x0?void 0x0:_0x2a6c4a['plural'],'pluralUtils':_0x197ffc});_0x2759e1&&!_0x37a9f3&&console[_0x2715c4(0x1ff)]('['+_0x44d07+']:\x20Translation\x20for\x20key\x20\x27'+_0x350b06+_0x2715c4(0x216));if(_0x2a6c4a===null||_0x2a6c4a===void 0x0?void 0x0:_0x2a6c4a['processTags'])return formatMsg(_0x2fbecc,_0x2a6c4a===null||_0x2a6c4a===void 0x0?void 0x0:_0x2a6c4a[_0x2715c4(0x1f3)],!![]);return formatMsg(_0x2fbecc,_0x2a6c4a===null||_0x2a6c4a===void 0x0?void 0x0:_0x2a6c4a[_0x2715c4(0x1f3)],![]);}return{'t':_0x38fd66,'lang':_0x44d07};};export{I18nContext,I18nProvider,getTranslations,useTranslation};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckbox/i18n",
3
- "version": "0.0.2-dev.5",
3
+ "version": "0.0.4",
4
4
  "description": "i18n functionality",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",