@ckbox/i18n 0.0.2-dev.5 → 0.0.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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
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 _0x7c8c5f=_0x2c18;(function(_0x202fa2,_0x306854){const _0x431794=_0x2c18,_0x30e5e8=_0x202fa2();while(!![]){try{const _0xc7a74d=-parseInt(_0x431794(0x121))/0x1+parseInt(_0x431794(0x11e))/0x2+-parseInt(_0x431794(0x109))/0x3+parseInt(_0x431794(0x103))/0x4+-parseInt(_0x431794(0x117))/0x5+-parseInt(_0x431794(0x108))/0x6+parseInt(_0x431794(0x123))/0x7*(parseInt(_0x431794(0x10d))/0x8);if(_0xc7a74d===_0x306854)break;else _0x30e5e8['push'](_0x30e5e8['shift']());}catch(_0x11e457){_0x30e5e8['push'](_0x30e5e8['shift']());}}}(_0x3d11,0x7cf08));import*as _0x1b9f41 from'react';import{__rest}from'tslib';import{sprintf}from'sprintf-js';const I18nContext=_0x1b9f41[_0x7c8c5f(0x120)]({'changeLang':()=>{},'debug':![],'lang':'en','resources':{}});function _0x2c18(_0x543884,_0x51aedd){const _0x3d1139=_0x3d11();return _0x2c18=function(_0x2c18f7,_0x387ca5){_0x2c18f7=_0x2c18f7-0xfe;let _0x1f5d9e=_0x3d1139[_0x2c18f7];return _0x1f5d9e;},_0x2c18(_0x543884,_0x51aedd);}function reducer(_0xf65c60,_0xd01b){const _0x20e7db=_0x7c8c5f;switch(_0xd01b['type']){case _0x20e7db(0xff):return Object[_0x20e7db(0x113)](Object[_0x20e7db(0x113)]({},_0xf65c60),{'lang':_0xd01b[_0x20e7db(0x11c)]});case _0x20e7db(0x10e):return Object[_0x20e7db(0x113)](Object[_0x20e7db(0x113)]({},_0xf65c60),{'lang':_0xd01b['payload'][_0x20e7db(0x115)],'resources':Object[_0x20e7db(0x113)](Object['assign']({},_0xf65c60['resources']),{[_0xd01b[_0x20e7db(0x11c)][_0x20e7db(0x115)]]:_0xd01b['payload'][_0x20e7db(0x102)]})});}}const useI18n=({debug:debug=![],loadURL:_0x16b227,lang:_0x306d46='en',resources:_0x591ed3={}})=>{const _0x48795c=_0x7c8c5f,[{lang:_0x2b5740,resources:_0x4211f9},_0x25b1ce]=_0x1b9f41['useReducer'](reducer,{'lang':_0x306d46,'resources':_0x591ed3});_0x1b9f41[_0x48795c(0x106)](()=>{const _0x26ad74=_0x48795c;if(_0x4211f9[_0x2b5740]||!_0x16b227)return;fetch(_0x16b227(_0x2b5740))[_0x26ad74(0x11b)](_0x1ab56f=>_0x1ab56f[_0x26ad74(0x10c)]())[_0x26ad74(0x11b)](_0xbb0c5b=>{_0x25b1ce({'type':'loadTranslations','payload':{'lang':_0x2b5740,'translations':_0xbb0c5b}});});},[_0x2b5740,_0x16b227,_0x4211f9]);const _0x93de3d=_0xe6eaa9=>{_0x25b1ce({'type':'changeLang','payload':_0xe6eaa9});};return{'changeLang':_0x93de3d,'debug':debug,'lang':_0x2b5740,'resources':_0x4211f9};},I18nProvider=_0xe52e08=>{const _0x4d8d20=_0x7c8c5f;var {children:_0x33a492}=_0xe52e08,_0xcf525a=__rest(_0xe52e08,['children']);const _0x15ee32=useI18n(_0xcf525a);return _0x1b9f41[_0x4d8d20(0x125)](I18nContext[_0x4d8d20(0x105)],{'value':_0x15ee32},_0x33a492);},getTranslations=_0x556ab8=>{const _0x39dedf=_0x7c8c5f;var _0x3f2da9,_0x44de6d;const _0x25240a=typeof globalThis!==_0x39dedf(0x116)?globalThis:global||self;return(_0x44de6d=(_0x3f2da9=_0x25240a===null||_0x25240a===void 0x0?void 0x0:_0x25240a[_0x39dedf(0x111)])===null||_0x3f2da9===void 0x0?void 0x0:_0x3f2da9[_0x556ab8])!==null&&_0x44de6d!==void 0x0?_0x44de6d:{};},defaultPlural=(_0x42157c,_0x5b2f89=0x1)=>{const _0x32fc17=_0x7c8c5f;return _0x5b2f89===0x1?_0x42157c:_0x42157c+_0x32fc17(0xfe);},plPlural=(_0x53a19e,_0x2405cc=0x1)=>{if(_0x2405cc===0x1)return _0x53a19e+'_0';else{if(_0x2405cc%0xa>=0x2&&_0x2405cc%0xa<=0x4&&(_0x2405cc%0x64<0xc||_0x2405cc%0x64>0xe))return _0x53a19e+'_1';else return _0x2405cc!=0x1&&_0x2405cc%0xa>=0x0&&_0x2405cc%0xa<=0x1||_0x2405cc%0xa>=0x5&&_0x2405cc%0xa<=0x9||_0x2405cc%0x64>=0xc&&_0x2405cc%0x64<=0xe?_0x53a19e+'_2':_0x53a19e+'_3';}},plurals={'default':defaultPlural,'en':defaultPlural,'pl':plPlural},getPluralKeyFn=_0x4d8dc4=>{return plurals[_0x4d8dc4]?plurals[_0x4d8dc4]:plurals['default'];},TAG_REGEX=/<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,ALLOWED_TAGS=['em',_0x7c8c5f(0x11a),_0x7c8c5f(0x112)],getMsg=(_0x28edb1,_0x5544e5,_0x385c57={},_0xb282df)=>{const _0x28fc09=_0x7c8c5f;if(_0x385c57[_0x5544e5]&&(_0xb282df===null||_0xb282df===void 0x0?void 0x0:_0xb282df[_0x28fc09(0x11f)])===undefined)return{'found':!![],'msg':_0x385c57[_0x5544e5]};const _0x52daac=Object['keys'](_0x385c57)[_0x28fc09(0x104)](_0x20fbfe=>_0x20fbfe[_0x28fc09(0x100)](_0x5544e5)===0x0);if(_0x52daac[_0x28fc09(0x10a)]===0x0)return{'found':![],'msg':_0x5544e5};const _0x41e4fe=getPluralKeyFn(_0x28edb1)(_0x5544e5,_0xb282df===null||_0xb282df===void 0x0?void 0x0:_0xb282df['plural']);return{'found':!![],'msg':_0x385c57[_0x41e4fe]};},parseMsgTags=_0x4a683b=>{const _0x493011=_0x7c8c5f,_0x151ebe=[];let _0x3ea327=0x0,_0x37214;while((_0x37214=TAG_REGEX[_0x493011(0x10b)](_0x4a683b))!==null){const _0x2dad28=_0x37214[0x0],{index:_0x45c15b}=_0x37214,_0x38499d=_0x2dad28['charAt'](0x1)==='/',_0x15015d=_0x38499d?_0x2dad28[_0x493011(0x10f)](0x2,-0x1):_0x2dad28[_0x493011(0x10f)](0x1,-0x1),_0x38339b=ALLOWED_TAGS['includes'](_0x15015d);if(!_0x38339b)continue;const _0x5d4cc1=_0x4a683b['slice'](_0x3ea327,_0x45c15b);if(!_0x5d4cc1){_0x3ea327=_0x45c15b+_0x2dad28[_0x493011(0x10a)];continue;}_0x38499d?_0x151ebe[_0x493011(0x118)]({'type':_0x493011(0x122),'name':_0x2dad28[_0x493011(0x10f)](0x2,-0x1),'content':_0x5d4cc1}):_0x151ebe[_0x493011(0x118)]({'type':_0x493011(0x101),'content':_0x5d4cc1}),_0x3ea327=_0x45c15b+_0x2dad28['length'];}return _0x3ea327<_0x4a683b['length']&&_0x151ebe[_0x493011(0x118)]({'type':_0x493011(0x101),'content':_0x4a683b[_0x493011(0x10f)](_0x3ea327)}),_0x151ebe;};function formatMsgWithTags(_0x46434f){const _0x30a800=parseMsgTags(_0x46434f),_0x251d05=_0x30a800['map'](({content:_0x19d22f,type:_0x1861ff,name:_0x324306},_0x53de45)=>{const _0x3dcd15=_0x2c18,_0x46911f=_0x1861ff!==_0x3dcd15(0x101)&&_0x324306?_0x324306:_0x1b9f41[_0x3dcd15(0x11d)];return _0x1b9f41[_0x3dcd15(0x125)](_0x46911f,{'key':''+_0x53de45},_0x19d22f);});return _0x251d05;}function _0x3d11(){const _0x4d7acc=['CKBOX_TRANSLATIONS','code','assign',']:\x20Translation\x20for\x20key\x20\x27','lang','undefined','941295PRKSDK','push','values','strong','then','payload','Fragment','601022PATUlO','plural','createContext','80628BgVLXN','tag','1106dCaCrp','processTags','createElement','_plural','changeLang','indexOf','text','translations','3051756ckDuNd','filter','Provider','useEffect','\x27\x20is\x20missing.','4019832KXNGtC','2619141EnHdWL','length','exec','json','63808SSEjxH','loadTranslations','slice','useContext'];_0x3d11=function(){return _0x4d7acc;};return _0x3d11();}function formatMsg(_0x5b93f4,_0x307bcd,_0x440a92){const _0x202fc7=sprintf(_0x5b93f4,..._0x307bcd!==null&&_0x307bcd!==void 0x0?_0x307bcd:[]);if(!_0x440a92)return _0x202fc7;return formatMsgWithTags(_0x202fc7);}const useTranslation=()=>{const _0x229b63=_0x7c8c5f,{lang:_0x3e9762,debug:_0x3f8625,resources:_0x46b1b0}=_0x1b9f41[_0x229b63(0x110)](I18nContext);function _0x9c9d37(_0x4758e7,_0x1390b2){const _0x2ee5d8=_0x229b63,{found:_0x5a331a,msg:_0x2455e9}=getMsg(_0x3e9762,_0x4758e7,_0x46b1b0[_0x3e9762],{'plural':_0x1390b2===null||_0x1390b2===void 0x0?void 0x0:_0x1390b2[_0x2ee5d8(0x11f)]});_0x3f8625&&!_0x5a331a&&console['log']('['+_0x3e9762+_0x2ee5d8(0x114)+_0x4758e7+_0x2ee5d8(0x107));if(_0x1390b2===null||_0x1390b2===void 0x0?void 0x0:_0x1390b2[_0x2ee5d8(0x124)])return formatMsg(_0x2455e9,_0x1390b2===null||_0x1390b2===void 0x0?void 0x0:_0x1390b2['values'],!![]);return formatMsg(_0x2455e9,_0x1390b2===null||_0x1390b2===void 0x0?void 0x0:_0x1390b2[_0x2ee5d8(0x119)],![]);}return{'t':_0x9c9d37,'lang':_0x3e9762};};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.2",
4
4
  "description": "i18n functionality",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",