All Projects → Ghost---Shadow → I18nize React

Ghost---Shadow / I18nize React

Licence: mit
Internationalize react apps within a lunch break

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to I18nize React

React Ast
render abstract syntax trees with react
Stars: ✭ 160 (-58.87%)
Mutual labels:  babel, ast, abstract-syntax-tree
Babel Plugin React Persist
Automatically useCallback() & useMemo(); memoize inline functions
Stars: ✭ 91 (-76.61%)
Mutual labels:  babel, ast, babel-plugin
Astexplorer.app
https://astexplorer.net with ES Modules support and Hot Reloading
Stars: ✭ 65 (-83.29%)
Mutual labels:  babel, ast, babel-plugin
Babel Plugin React Intl Auto
i18n for the component age. Auto management react-intl ID.
Stars: ✭ 203 (-47.81%)
Mutual labels:  babel, babel-plugin, i18n
tsquery-playground
Playground for TSQuery
Stars: ✭ 30 (-92.29%)
Mutual labels:  ast, abstract-syntax-tree
babel-plugin-transform-html-import-to-string
Turn HTML imports (and export from) into constant strings
Stars: ✭ 22 (-94.34%)
Mutual labels:  babel, babel-plugin
babel-plugin-remove-test-ids
🐠 Babel plugin to strip `data-test-id` HTML attributes
Stars: ✭ 40 (-89.72%)
Mutual labels:  babel, babel-plugin
Babel Blade
(under new management!) ⛸️Solve the Double Declaration problem with inline GraphQL. Babel plugin/macro that works with any GraphQL client!
Stars: ✭ 266 (-31.62%)
Mutual labels:  babel, babel-plugin
core-web
like core-js but for Web APIs (based on polyfill.io)
Stars: ✭ 34 (-91.26%)
Mutual labels:  babel, babel-plugin
babel-plugin-syntax-pipeline
Allow parsing of pipeline operator |>
Stars: ✭ 23 (-94.09%)
Mutual labels:  babel, babel-plugin
Javaparser
Java 1-15 Parser and Abstract Syntax Tree for Java, including preview features to Java 13
Stars: ✭ 3,972 (+921.08%)
Mutual labels:  ast, abstract-syntax-tree
babel-plugin-transform-replace-expressions
A Babel plugin for replacing expressions with other expressions
Stars: ✭ 23 (-94.09%)
Mutual labels:  babel, babel-plugin
verilogAST-cpp
C++17 implementation of an AST for Verilog code generation
Stars: ✭ 14 (-96.4%)
Mutual labels:  ast, abstract-syntax-tree
ast-builder
Build your ASTs directly from code
Stars: ✭ 18 (-95.37%)
Mutual labels:  ast, abstract-syntax-tree
babel-plugin-source-map-support
A Babel plugin which automatically makes stack traces source-map aware
Stars: ✭ 41 (-89.46%)
Mutual labels:  babel, babel-plugin
Grafoo
A GraphQL Client and Toolkit
Stars: ✭ 264 (-32.13%)
Mutual labels:  babel, babel-plugin
Effectfuljs
JavaScript embedded effects compiler
Stars: ✭ 287 (-26.22%)
Mutual labels:  babel, babel-plugin
Babel Plugin Module Resolver
Custom module resolver plugin for Babel
Stars: ✭ 3,134 (+705.66%)
Mutual labels:  babel, babel-plugin
Reshape
💠 transform html with javascript plugins
Stars: ✭ 314 (-19.28%)
Mutual labels:  babel, ast
Babel Plugin Tailwind Components
Use Tailwind with any CSS-in-JS library
Stars: ✭ 320 (-17.74%)
Mutual labels:  babel, babel-plugin

i18nize-react

Internationalize legacy react apps in a lunch break.

i18nize-react finds and replaces all the hardcoded string literals in your react project with i18n bindings. It uses babel to walk on react components and process them.

diff

Getting started

  1. First install the i18nize-react globally using npm
npm i -g i18nize-react
  1. Now in your react app run
npm install i18next

Tested on i18next other variants should work with minor changes.

Make sure there are no unstaged changes, you may need to git reset --hard.

  1. Now run.
i18nize-react
  1. Go for lunch

  2. Run your favourite linter to clean things up.

  3. It should create four files src/i18n/init.js, src/i18n/keys.js, src/i18n/english.js, src/i18n/chinese.js. Add the line import ./i18n/init.js; in your App's entry point. Usually it is src/index.js.

  4. Change the lng key in your browser's local storage to see changes.

Contributions

Create an issue ticket with a before and after code snippets, before writing any code and raising a PR.

For bugs create a minimum reproducible piece of code with original, received and expected snippets.

Make sure to read wont-fix.md.

Troubleshooting

  1. Sometimes i18ize-react might conflict with the babel plugins installed in your project. If that happens go up one folder (cd ..) and then run i18ize-react ./your-dir ./your-dir

  2. By default i18ize-react assumes that your code is in <your workspace dir>/src but if you want to change that you can use the third argument. e.g. i18ize-react ./ ./ web will crawl <your workspace dir>/web instead.

  3. Constant initialization outside react lifecycle is not guaranteed. To resolve this, move all initialized strings inside the component.

// String 1 might not load correctly 
const string1 = i18next.t(k.STRING1);
const MyComponent = () => {
  // String 2 will load correctly
  const string2 = i18next.t(k.STRING2);

  return (
    <div>
      {string1}
      {string2}
    </div>
  )
}
  1. TIP: Babel's parse and generate often shifts code around which causes files, with no programatic change, to show up in git diff. Sometimes running the linter alone does not fix this problem. A good way to fix this problem is to do a dry run i18nize-react ./ ./ src true, run your linter and commit the code. Now run i18nize-react to run the transform and lint again. Now only the transformed changes should show up in git diff.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].