babel-plugin-string-to-lingui

1.0.0 • Public • Published

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

  1. 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:

  1. In menu: View -> Command pallete...
  2. >Tasks: Configure Task
  3. Task from tasks.json template
  4. 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"
        }
    ]
}
  1. Open command pallete and ask it to open View -> Command pallete... -> Preferences: Open Keyboard Shortcuts (JSON)
  2. Add this:
    {
        "key": "cmd+y",
        "command": "workbench.action.tasks.runTask",
        "args": "Lingui transform"
    }
  1. Open any file and press cmd+e to apply codemod on file.
  2. Also you could run Terminal -> Run task... -> Find in the list "Lingui transform" -> Enter
  3. Enjoy

Readme

Keywords

Package Sidebar

Install

npm i babel-plugin-string-to-lingui

Weekly Downloads

7

Version

1.0.0

License

MIT

Unpacked Size

29.9 kB

Total Files

10

Last publish

Collaborators

  • igorpleo