Installation
With yarn
:
yarn add estafette-intl
With npm
:
npm install estafette-intl
Getting started
Steps:
- Create internalization
- Create messages
- Use internalization using useIntl
Create internalization
import CreateIntl from 'estafette-intl'; ReactDOM;
Create messages
import createMessages from 'estafette-intl'; const messages = ;
Use internalization using useIntl
import useIntl from 'estafette-intl'; const App = const t = ; return <h1></h1>;;
API
CreateIntl
Internalization creator
Props
defaultLocale
(String) - it can be simple string, that you will be able to change fromuseIntl
usingsetLocale
messages
(Object) -Messages
fromcreateMessage
createMessage
function helper, gets array of messages, parses all of them into an object and checks for dublicates
Arguments
messages
(Array) -Messages
Messages
typescript interface
Interface
useIntl
hook helper for using internalization
Returns
t
(Function) - a function that requireslocale
(String) argument and returns bylocale
keyword necessary textlocale
(String) - current localesetLocale
(Function) - a function that requiresnewLocale
(String) argument and change current locale to the new locale.