babel-plugin-localize
modify static strings in jsx code to localization friendly formats
example
input
const jsxText = <> <p>hello world</p> <Static>hello world</Static> </>;const jsxAttribute = <Title ="awesome" ="title" />;
output
import localize from './localizer'; const jsxText = <> <p></p> <Static>hello world</Static> </>;const jsxAttribute = <Title = ="title" />; const localizeKeyMap = "loc_0": "hello world" "loc_1": "awesome";
options
installation
npm
npm install --save-dev babel-plugin-localize
yarn
yarn add -D babel-plugin-localize
usage
.babelrc
(Recommended)
via .babelrc
via CLI
babel --plugins localize script.js
via Node API
;