@@ -98,7 +98,7 @@ <h2>API</h2>
9898 < p > < a href ="https://trigensoftware.github.io/i18n-for-react/index.html "> Description of this methods you can find in Documentation.</ a > </ p >
9999 < p > Basic API is same as in < a href ="https://github.com/TrigenSoftware/i18n-for-browser "> < code > i18n-for-browser</ code > module.</ a > </ p >
100100 < a href ="#createi18nprovider " id ="createi18nprovider " style ="color: inherit; text-decoration: none; ">
101- < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/interfaces/_provider_.ii18nproviderconfig. html "> createI18nProvider</ a > </ h3 >
101+ < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/modules/_src_createi18nprovider_. html#createi18nprovider "> createI18nProvider</ a > </ h3 >
102102 </ a >
103103 < p > Create < code > I18nContext</ code > and < code > I18nProvider</ code > with given methods.</ p >
104104 < details >
@@ -114,7 +114,11 @@ <h3><a href="https://trigensoftware.github.io/i18n-for-react/interfaces/_provide
114114 < span class ="hljs-comment "> /**
115115 * Context with config and methods.
116116 */</ span >
117- I18nContext
117+ I18nContext,
118+ < span class ="hljs-comment "> /**
119+ * Hook to recieve config and methods.
120+ */</ span >
121+ useI18n
118122} = createI18nProvider(
119123 < span class ="hljs-comment "> /**
120124 * Methods for binding and providing.
@@ -131,30 +135,9 @@ <h3><a href="https://trigensoftware.github.io/i18n-for-react/interfaces/_provide
131135 < span class ="hljs-attr "> cookieName</ span > : < span class ="hljs-string "> 'yourcookiename'</ span >
132136 }
133137);</ code > </ pre >
134- </ details >
135- < a href ="#createi18nhook " id ="createi18nhook " style ="color: inherit; text-decoration: none; ">
136- < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/interfaces/_provider_.ii18nproviderconfig.html "> createI18nHook</ a > </ h3 >
137- </ a >
138- < p > Create hook from context.</ p >
139- < details >
140- < summary > Usage example</ summary >
141- < pre > < code class ="language-js "> < span class ="hljs-comment "> /**
142- * Basic example
143- */</ span >
144- < span class ="hljs-keyword "> const</ span > useI18n = createI18nHook(I18nContext);
145- < span class ="hljs-comment "> /**
146- * Then you can use this hook
147- */</ span >
148- < span class ="hljs-function "> < span class ="hljs-keyword "> function</ span > < span class ="hljs-title "> SomeComponent</ span > (< span class ="hljs-params "> </ span > ) </ span > {
149- < span class ="hljs-keyword "> const</ span > {
150- __
151- } = useI18n();
152-
153- < span class ="hljs-keyword "> return</ span > __< span class ="hljs-string "> `cat`</ span > ;
154- }</ code > </ pre >
155138 </ details >
156139 < a href ="#i18nprovider " id ="i18nprovider " style ="color: inherit; text-decoration: none; ">
157- < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/interfaces/_provider_.ii18nproviderconfig. html "> I18nProvider</ a > </ h3 >
140+ < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/modules/_src_createi18nprovider_. html#createi18nprovider "> I18nProvider</ a > </ h3 >
158141 </ a >
159142 < p > Configurator and provider of < code > i18n</ code > instance.</ p >
160143 < details >
@@ -191,9 +174,38 @@ <h3><a href="https://trigensoftware.github.io/i18n-for-react/interfaces/_provide
191174 {/* ... */}
192175 < span class ="hljs-tag "> </< span class ="hljs-name "> I18nProvider</ span > ></ span >
193176< span class ="hljs-tag "> </< span class ="hljs-name "> I18nProvider</ span > ></ span > </ span > </ code > </ pre >
177+ </ details >
178+ < a href ="#usei18n " id ="usei18n " style ="color: inherit; text-decoration: none; ">
179+ < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/modules/_src_createi18nprovider_.html#createi18nprovider "> useI18n</ a > </ h3 >
180+ </ a >
181+ < p > Hook to recieve config and methods.</ p >
182+ < details >
183+ < summary > Usage example</ summary >
184+ < pre > < code class ="language-js "> < span class ="hljs-comment "> /**
185+ * Basic example
186+ */</ span >
187+ < span class ="hljs-function "> < span class ="hljs-keyword "> function</ span > < span class ="hljs-title "> SomeComponent</ span > (< span class ="hljs-params "> </ span > ) </ span > {
188+ < span class ="hljs-keyword "> const</ span > {
189+ __
190+ } = useI18n();
191+
192+ < span class ="hljs-keyword "> return</ span > __< span class ="hljs-string "> `cat`</ span > ;
193+ }
194+ < span class ="hljs-comment "> /**
195+ * Fork instance
196+ */</ span >
197+ < span class ="hljs-function "> < span class ="hljs-keyword "> function</ span > < span class ="hljs-title "> SomeComponent</ span > (< span class ="hljs-params "> </ span > ) </ span > {
198+ < span class ="hljs-keyword "> const</ span > {
199+ __
200+ } = useI18n({
201+ < span class ="hljs-attr "> locales</ span > : < span class ="hljs-comment "> /* ... */</ span >
202+ });
203+
204+ < span class ="hljs-keyword "> return</ span > __< span class ="hljs-string "> `cat`</ span > ;
205+ }</ code > </ pre >
194206 </ details >
195207 < a href ="#rprintf " id ="rprintf " style ="color: inherit; text-decoration: none; ">
196- < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/modules/_rprintf_ .html#rprintf "> rprintf()</ a > </ h3 >
208+ < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/modules/_src_rprintf_ .html#rprintf "> rprintf()</ a > </ h3 >
197209 </ a >
198210 < p > Format string with wrappers.</ p >
199211 < details >
@@ -208,7 +220,7 @@ <h3><a href="https://trigensoftware.github.io/i18n-for-react/modules/_rprintf_.h
208220rprintf(< span class ="hljs-string "> 'Hi, <>John</>!'</ span > , [< span class ="hljs-function "> < span class ="hljs-params "> _</ span > =></ span > < span class ="hljs-string "> `<b>< span class ="hljs-subst "> ${_}</ span > </b>`</ span > ])</ code > </ pre >
209221 </ details >
210222 < a href ="#__x " id ="__x " style ="color: inherit; text-decoration: none; ">
211- < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/modules/_index_ .html#__x "> __x()</ a > </ h3 >
223+ < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/modules/_src_index_ .html#__x "> __x()</ a > </ h3 >
212224 </ a >
213225 < p > Same as < code > __()</ code > , but for JSX.</ p >
214226 < details >
@@ -223,7 +235,7 @@ <h3><a href="https://trigensoftware.github.io/i18n-for-react/modules/_index_.htm
223235__x(< span class ="hljs-string "> 'Hi, <>%s</>!'</ span > , < span class ="hljs-string "> 'John'</ span > , [< span class ="xml "> < span class ="hljs-tag "> << span class ="hljs-name "> b</ span > /></ span > </ span > ])</ code > </ pre >
224236 </ details >
225237 < a href ="#__xmf " id ="__xmf " style ="color: inherit; text-decoration: none; ">
226- < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/modules/_index_ .html#__xmf "> __xmf()</ a > </ h3 >
238+ < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/modules/_src_index_ .html#__xmf "> __xmf()</ a > </ h3 >
227239 </ a >
228240 < p > Same as < code > __mf()</ code > , but for JSX.</ p >
229241 < details >
@@ -238,7 +250,7 @@ <h3><a href="https://trigensoftware.github.io/i18n-for-react/modules/_index_.htm
238250__xmf(< span class ="hljs-string "> 'Hi, <>{username}</>!'</ span > , { < span class ="hljs-attr "> username</ span > : < span class ="hljs-string "> 'John'</ span > }, [< span class ="xml "> < span class ="hljs-tag "> << span class ="hljs-name "> b</ span > /></ span > </ span > ])</ code > </ pre >
239251 </ details >
240252 < a href ="#__xn " id ="__xn " style ="color: inherit; text-decoration: none; ">
241- < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/modules/_index_ .html#__xn "> __xn()</ a > </ h3 >
253+ < h3 > < a href ="https://trigensoftware.github.io/i18n-for-react/modules/_src_index_ .html#__xn "> __xn()</ a > </ h3 >
242254 </ a >
243255 < p > Same as < code > __n()</ code > , but for JSX.</ p >
244256 < details >
0 commit comments