babel-plugin-string-to-lingui
v1.0.0
Published
This plugin transforms string/jsxText/templates into lingui <Trans> and i18n
Downloads
63
Readme
babel-plugin-string-to-lingui
It's codemod for updating strings/jsxText/templates to 'lingui' and i18n
Usage
Install babel-codemod npm i -g babel-codemod
Then install in root of your project yarn add babel-plugin-string-to-lingui
You could run it:
codemod --plugin ./node_modules/babel-plugin-string-to-lingui/src/index.js app/scripts/pages
Also, you could run it with prettier
codemod --plugin ./node_modules/babel-plugin-string-to-lingui/src/index.js app/scripts/pages --printer prettier
Remove babel-plugin-string-to-lingui
from package.json
If there is any issues, let me know in the issues tab here at GitHub.
Limitations
- Do not convert '<' and '>' correctly
Integration with VS Code to do file by file
Preconditions:
npm i -g @babel/core babel-codemod babel-plugin-string-to-lingui
VS Code:
- In menu:
View -> Command pallete...
>Tasks: Configure Task
Task from tasks.json template
- Copy and paste this:
{
"version": "2.0.0",
"tasks": [
{
"label": "Lingui transform",
"type": "shell",
"command": "codemod -p /usr/local/lib/node_modules/babel-plugin-string-to-lingui/src/index.js ${file} --printer prettier"
}
]
}
- Open command pallete and ask it to open
View -> Command pallete... -> Preferences: Open Keyboard Shortcuts (JSON)
- Add this:
{
"key": "cmd+y",
"command": "workbench.action.tasks.runTask",
"args": "Lingui transform"
}
- Open any file and press cmd+e to apply codemod on file.
- Also you could run
Terminal -> Run task... -> Find in the list "Lingui transform" -> Enter
- Enjoy