babel-plugin-id
Literally all it does is it evaluates a function to its argument. Useful for translation collection, for example.
Function name defaults to __
.
Setup
Just add id
to the list of babel plugins, e.g. to .babelrc
:
Example
// Input:const text = ; // Output:const text = "Translate me";
Config
To change the function name, add an object with the fn
property to your config:
This will evaluate functions named t
.
Example
// Input:const text = ; // Output:const text = "Translate me";
License
MIT