@ckbox/i18n 0.0.2 → 0.0.3

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 _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};
4
+ const _0x196143=_0x2772;(function(_0x251749,_0x215e3a){const _0x5b614f=_0x2772,_0x373036=_0x251749();while(!![]){try{const _0x2827a9=parseInt(_0x5b614f(0x190))/0x1+parseInt(_0x5b614f(0x1ab))/0x2+parseInt(_0x5b614f(0x19d))/0x3+parseInt(_0x5b614f(0x18b))/0x4+parseInt(_0x5b614f(0x1b2))/0x5*(-parseInt(_0x5b614f(0x1a3))/0x6)+-parseInt(_0x5b614f(0x192))/0x7+parseInt(_0x5b614f(0x18a))/0x8*(-parseInt(_0x5b614f(0x1bb))/0x9);if(_0x2827a9===_0x215e3a)break;else _0x373036['push'](_0x373036['shift']());}catch(_0x20b0b2){_0x373036['push'](_0x373036['shift']());}}}(_0x5119,0xe37a4));import*as _0x8d38d4 from'react';import{__rest}from'tslib';function _0x2772(_0x1d6e79,_0x2e0d73){const _0x5119dc=_0x5119();return _0x2772=function(_0x2772ea,_0x3117a6){_0x2772ea=_0x2772ea-0x188;let _0x2870cf=_0x5119dc[_0x2772ea];return _0x2870cf;},_0x2772(_0x1d6e79,_0x2e0d73);}import{sprintf}from'sprintf-js';class Plural{constructor(_0x109028){const _0xa26911=_0x2772;this[_0xa26911(0x19c)]=_0x109028;try{this[_0xa26911(0x1a9)]=new Intl[(_0xa26911(0x1b6))](_0x109028);}catch(_0x74b5bd){console[_0xa26911(0x19e)](_0xa26911(0x188));}}[_0x196143(0x1a7)](_0x4f4ab9,_0x5b11ff){const _0x2ebdb5=_0x196143;if(!this[_0x2ebdb5(0x1a9)])return _0x4f4ab9+'_one';const _0x121363=this[_0x2ebdb5(0x1a9)]['select'](_0x5b11ff);return _0x4f4ab9+'_'+_0x121363;}}Plural[_0x196143(0x1ae)]=_0x3ef644=>{try{return Intl['PluralRules']['supportedLocalesOf']([_0x3ef644])['length']>0x0;}catch(_0x317467){return![];}};const I18nContext=_0x8d38d4[_0x196143(0x1ad)]({'changeLang':()=>{},'debug':![],'lang':'en','resources':{},'pluralUtils':new Plural('en')});function reducer(_0x4ab1ed,_0x18cb8d){const _0x38d978=_0x196143;switch(_0x18cb8d[_0x38d978(0x18d)]){case _0x38d978(0x1ba):return Object[_0x38d978(0x1b5)](Object[_0x38d978(0x1b5)]({},_0x4ab1ed),{'lang':_0x18cb8d[_0x38d978(0x1b7)]});case _0x38d978(0x1a8):return Object[_0x38d978(0x1b5)](Object[_0x38d978(0x1b5)]({},_0x4ab1ed),{'lang':_0x18cb8d[_0x38d978(0x1b7)]['lang'],'resources':Object[_0x38d978(0x1b5)](Object[_0x38d978(0x1b5)]({},_0x4ab1ed[_0x38d978(0x1a0)]),{[_0x18cb8d[_0x38d978(0x1b7)][_0x38d978(0x19c)]]:_0x18cb8d['payload'][_0x38d978(0x1b4)]})});}}function _0x5119(){const _0x4b8518=['Plural\x20form\x20for\x20language\x20\x22','filter','then','20hrOzqG','keys','translations','assign','PluralRules','payload',']:\x20Translation\x20for\x20key\x20\x27','map','changeLang','308349fAlguc','Plural\x20rules\x20could\x20not\x20be\x20created.\x20Perhaps\x20`Intl.PluralRules`\x20is\x20not\x20supported?','pluralUtils','120DZRIXE','766824CkvSXr','undefined','type','children','useContext','282947ahlTHt','length','4654573AsAYsn','useEffect','createElement','indexOf','log','processTags','values','push','exec','json','lang','4541235fWlGxW','warn','CKBOX_TRANSLATIONS','resources','\x22\x20is\x20not\x20supported.','useReducer','495654taVTcd','charAt','code','text','getKey','loadTranslations','_rules','Provider','905280YwcwEr','slice','createContext','isSupported'];_0x5119=function(){return _0x4b8518;};return _0x5119();}const useI18n=({debug:debug=![],loadURL:_0x386b6d,lang:_0x55b8f6='en',resources:_0x1e8306={}})=>{const _0x4d3f6a=_0x196143,[{lang:_0x5ac6a0,resources:_0x262cdc},_0x4ae863]=_0x8d38d4[_0x4d3f6a(0x1a2)](reducer,{'lang':_0x55b8f6,'resources':_0x1e8306});_0x8d38d4[_0x4d3f6a(0x193)](()=>{const _0x5aba50=_0x4d3f6a,_0x453af8=Plural[_0x5aba50(0x1ae)](_0x5ac6a0);!_0x453af8&&console['warn'](_0x5aba50(0x1af)+_0x5ac6a0+_0x5aba50(0x1a1));},[_0x5ac6a0]),_0x8d38d4[_0x4d3f6a(0x193)](()=>{const _0x3a763b=_0x4d3f6a;if(_0x262cdc[_0x5ac6a0]||!_0x386b6d)return;fetch(_0x386b6d(_0x5ac6a0))[_0x3a763b(0x1b1)](_0x27c98b=>_0x27c98b[_0x3a763b(0x19b)]())[_0x3a763b(0x1b1)](_0x10f5dd=>{const _0x531ff1=_0x3a763b;_0x4ae863({'type':_0x531ff1(0x1a8),'payload':{'lang':_0x5ac6a0,'translations':_0x10f5dd}});});},[_0x5ac6a0,_0x386b6d,_0x262cdc]);const _0x4fb8eb=_0x2de34f=>{const _0x17fc93=_0x4d3f6a;_0x4ae863({'type':_0x17fc93(0x1ba),'payload':_0x2de34f});};return{'changeLang':_0x4fb8eb,'debug':debug,'lang':_0x5ac6a0,'pluralUtils':new Plural(_0x5ac6a0),'resources':_0x262cdc};},I18nProvider=_0xd189e6=>{const _0x53c421=_0x196143;var {children:_0x4f2bed}=_0xd189e6,_0x834e85=__rest(_0xd189e6,[_0x53c421(0x18e)]);const _0x487ea8=useI18n(_0x834e85);return _0x8d38d4[_0x53c421(0x194)](I18nContext[_0x53c421(0x1aa)],{'value':_0x487ea8},_0x4f2bed);},getTranslations=_0x33e0d7=>{const _0x23ba93=_0x196143;var _0xf37143,_0x568a51;const _0x3f6097=typeof globalThis!==_0x23ba93(0x18c)?globalThis:global||self;return(_0x568a51=(_0xf37143=_0x3f6097===null||_0x3f6097===void 0x0?void 0x0:_0x3f6097[_0x23ba93(0x19f)])===null||_0xf37143===void 0x0?void 0x0:_0xf37143[_0x33e0d7])!==null&&_0x568a51!==void 0x0?_0x568a51:{};},TAG_REGEX=/<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,ALLOWED_TAGS=['em','strong',_0x196143(0x1a5)],getMsg=(_0x172b5f,_0x52da84={},_0x50cb95)=>{const _0x80a3c=_0x196143,_0x5b5396=_0x50cb95['plural'];if(_0x52da84[_0x172b5f]&&_0x5b5396===undefined)return{'found':!![],'msg':_0x52da84[_0x172b5f]};const _0x2d3563=Object[_0x80a3c(0x1b3)](_0x52da84)[_0x80a3c(0x1b0)](_0x47c6ff=>_0x47c6ff[_0x80a3c(0x195)](_0x172b5f)===0x0);if(_0x2d3563['length']===0x0||_0x5b5396===undefined)return{'found':![],'msg':_0x172b5f};const _0x29f208=_0x50cb95[_0x80a3c(0x189)][_0x80a3c(0x1a7)](_0x172b5f,_0x5b5396);return{'found':!![],'msg':_0x52da84[_0x29f208]};},parseMsgTags=_0x6976fa=>{const _0x849a3d=_0x196143,_0x54f5c8=[];let _0xba7b96=0x0,_0x147a13;while((_0x147a13=TAG_REGEX[_0x849a3d(0x19a)](_0x6976fa))!==null){const _0x53655d=_0x147a13[0x0],{index:_0x384c96}=_0x147a13,_0x3c89aa=_0x53655d[_0x849a3d(0x1a4)](0x1)==='/',_0x2ec8bd=_0x3c89aa?_0x53655d[_0x849a3d(0x1ac)](0x2,-0x1):_0x53655d['slice'](0x1,-0x1),_0x36eaa5=ALLOWED_TAGS['includes'](_0x2ec8bd);if(!_0x36eaa5)continue;const _0x3ae3e5=_0x6976fa['slice'](_0xba7b96,_0x384c96);if(!_0x3ae3e5){_0xba7b96=_0x384c96+_0x53655d[_0x849a3d(0x191)];continue;}_0x3c89aa?_0x54f5c8[_0x849a3d(0x199)]({'type':'tag','name':_0x53655d[_0x849a3d(0x1ac)](0x2,-0x1),'content':_0x3ae3e5}):_0x54f5c8['push']({'type':'text','content':_0x3ae3e5}),_0xba7b96=_0x384c96+_0x53655d['length'];}return _0xba7b96<_0x6976fa[_0x849a3d(0x191)]&&_0x54f5c8[_0x849a3d(0x199)]({'type':_0x849a3d(0x1a6),'content':_0x6976fa[_0x849a3d(0x1ac)](_0xba7b96)}),_0x54f5c8;};function formatMsgWithTags(_0x4bc29a){const _0xb4f157=_0x196143,_0x5a4a45=parseMsgTags(_0x4bc29a),_0x2b9a64=_0x5a4a45[_0xb4f157(0x1b9)](({content:_0x3eed08,type:_0x568e35,name:_0x27ff3c},_0x59b472)=>{const _0x4b85e8=_0xb4f157,_0x1a11f9=_0x568e35!=='text'&&_0x27ff3c?_0x27ff3c:_0x8d38d4['Fragment'];return _0x8d38d4[_0x4b85e8(0x194)](_0x1a11f9,{'key':''+_0x59b472},_0x3eed08);});return _0x2b9a64;}function formatMsg(_0x5ed8c5,_0x3e0d23,_0x5be014){const _0x3b8d16=sprintf(_0x5ed8c5,..._0x3e0d23!==null&&_0x3e0d23!==void 0x0?_0x3e0d23:[]);if(!_0x5be014)return _0x3b8d16;return formatMsgWithTags(_0x3b8d16);}const useTranslation=()=>{const _0x23a994=_0x196143,{lang:_0x43f09c,debug:_0x787384,pluralUtils:_0xb958fe,resources:_0x4012c6}=_0x8d38d4[_0x23a994(0x18f)](I18nContext);function _0x4a9598(_0x5503f5,_0x4072cd){const _0x3dc589=_0x23a994,{found:_0x36fa27,msg:_0x564295}=getMsg(_0x5503f5,_0x4012c6[_0x43f09c],{'plural':_0x4072cd===null||_0x4072cd===void 0x0?void 0x0:_0x4072cd['plural'],'pluralUtils':_0xb958fe});_0x787384&&!_0x36fa27&&console[_0x3dc589(0x196)]('['+_0x43f09c+_0x3dc589(0x1b8)+_0x5503f5+'\x27\x20is\x20missing.');if(_0x4072cd===null||_0x4072cd===void 0x0?void 0x0:_0x4072cd[_0x3dc589(0x197)])return formatMsg(_0x564295,_0x4072cd===null||_0x4072cd===void 0x0?void 0x0:_0x4072cd[_0x3dc589(0x198)],!![]);return formatMsg(_0x564295,_0x4072cd===null||_0x4072cd===void 0x0?void 0x0:_0x4072cd['values'],![]);}return{'t':_0x4a9598,'lang':_0x43f09c};};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",
3
+ "version": "0.0.3",
4
4
  "description": "i18n functionality",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",