Installation
To install, jus run:
or, with Yarn:
Setup
Babel Mercurio Helmet plugin
The Babel Mercurio Helmet plugin extracts the default values from your <Mercurio>
tags and adds them to the locales files.
To install the Babel plugin, you must add this to your Babel config file (usually .babelrc
):
Options
locales
(required):
These are going to be the available languages on your site. It's an array of strings with the locales names. Following the above example, the follow locales files will be generated: pt.json
and en.json
.
filesOutput
(optional):
This is where all the Mercurio's generated files will be outputted. if you don't specify this, it'll create and output in a folder called mercurio
in your project's root.
Webpack Mercurio Boots plugin
The Webpack Mercurio Boots plugin will do multiple actions:
- Merge all the locales files generated by the Babel plugin into a unique file called
translations.json
. - "injects" it into the React components, so you don't need to manually import this.
- Watches the generated files for changes, so it can reload if you change some translation.
caution
This only works on webpack 4.x for now!
Add the following in your webpack config file: