i18n - GabrielVander/singles GitHub Wiki

Basic usage

To display a simple string like "Chat with your peers and form new relationships through the platform" you can simply use the useTranslation hook like so:

Code snippet

Breakdown

First you invoke the hook and pass a list of namespaces to load - usually only one named after the component in camelcase

Code snippet

Then wherever you'd place the desired string invoke the t method indexing the string key instead - the key is just the namespace followed by a colon and the string identifier

The just run yarn extract and a new json file will be generated under public/locales for all languages configured in the project. It will have the inputted namespace as name and will contain the inputted string identifier as a property. Then just fill in the desired string