i18n-for-react
Modern translation module for React.
Install
npm i i18n-for-react# or yarn add i18n-for-react
API
Module exposes next API:
// all i18n-for-browser exports, plus:;
Description of this methods you can find in Documentation.
Basic API is same as in i18n-for-browser
module.
createI18nProvider
Create I18nContext
and I18nProvider
with given methods.
Usage example
/** * Basic example */const /** * Config and methods provider. */ I18nProvider /** * Context with config and methods. */ I18nContext /** * Hook to recieve config and methods. */ useI18n} = ;
I18nProvider
Configurator and provider of i18n
instance.
Usage example
/** * Root context configuration */<I18nProvider ='en' => /* ... */</I18nProvider>/** * Fork context */<I18nProvider ='en' => /* ... */ <I18nProvider = > /* ... */ </I18nProvider></I18nProvider>
useI18n
Hook to recieve config and methods.
Usage example
/** * Basic example */ { const __ } = ; return __`cat`;}/** * Fork instance */ { const __ } = ; return __`cat`;}
rprintf()
Format string with wrappers.
Usage example
/** * Wrap with React-elements *//** * or handle with functions */
__x()
Same as __()
, but for JSX.
Usage example
/** * Same as `__()` *//** * And with wrappers */
__xmf()
Same as __mf()
, but for JSX.
Usage example
/** * Same as `__mf()` *//** * And with wrappers */
__xn()
Same as __n()
, but for JSX.
Usage example
/** * Same as `__xn()` *//** * And with wrappers */