{"id":14981937,"url":"https://github.com/ghost---shadow/i18nize-react","last_synced_at":"2025-04-04T17:10:41.505Z","repository":{"id":46937663,"uuid":"183746818","full_name":"Ghost---Shadow/i18nize-react","owner":"Ghost---Shadow","description":"Internationalize react apps within a lunch break","archived":false,"fork":false,"pushed_at":"2023-12-02T14:45:19.000Z","size":417,"stargazers_count":407,"open_issues_count":3,"forks_count":22,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-28T16:04:56.870Z","etag":null,"topics":["abstract-syntax-tree","ast","babel","babel-plugin","i18n","i18next","javascript","react","react-i18n"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ghost---Shadow.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-27T08:17:16.000Z","updated_at":"2025-03-13T22:51:33.000Z","dependencies_parsed_at":"2024-09-24T08:01:44.247Z","dependency_job_id":"07cc6a82-b187-4e1a-8fd0-30a2abe1c58c","html_url":"https://github.com/Ghost---Shadow/i18nize-react","commit_stats":{"total_commits":102,"total_committers":3,"mean_commits":34.0,"dds":0.06862745098039214,"last_synced_commit":"4f7d20409eb66bf547ba17e9c6f2a2a9fb1feeca"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghost---Shadow%2Fi18nize-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghost---Shadow%2Fi18nize-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghost---Shadow%2Fi18nize-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghost---Shadow%2Fi18nize-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ghost---Shadow","download_url":"https://codeload.github.com/Ghost---Shadow/i18nize-react/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217222,"owners_count":20903009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abstract-syntax-tree","ast","babel","babel-plugin","i18n","i18next","javascript","react","react-i18n"],"created_at":"2024-09-24T14:04:30.270Z","updated_at":"2025-04-04T17:10:41.482Z","avatar_url":"https://github.com/Ghost---Shadow.png","language":"JavaScript","readme":"# i18nize-react\n\nInternationalize legacy react apps in a lunch break.\n\n`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.\n\n![diff](./documentation/diff.png)\n\n## Getting started\n\n1. First install the `i18nize-react` globally using npm\n\n```sh\nnpm i -g i18nize-react\n```\n\n2. Now in your react app run\n\n```sh\nnpm install i18next\n```\nTested on `i18next` other variants should work with minor changes.\n\nMake sure there are no unstaged changes, you may need to `git reset --hard`.\n\n3. Now run.\n```sh\ni18nize-react\n```\n\n4. Go for lunch\n\n5. Run your favourite linter to clean things up.\n\n6. 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`.\n\n7. Change the `lng` key in your browser's local storage to see changes.\n\n## Contributions\n\nCreate an issue ticket with a before and after code snippets, before writing any code and raising a PR.\n\nFor bugs create a minimum reproducible piece of code with original, received and expected snippets.\n\nMake sure to read [wont-fix.md](./wont-fix.md).\n\n## Troubleshooting\n\n1. 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`\n\n2. By default `i18ize-react` assumes that your code is in `\u003cyour workspace dir\u003e/src` but if you want to change that you can use the third argument. e.g. `i18ize-react ./ ./ web` will crawl  `\u003cyour workspace dir\u003e/web` instead.\n\n3. Constant initialization outside react lifecycle is not guaranteed. To resolve this, move all initialized strings inside the component.\n\n```js\n// String 1 might not load correctly \nconst string1 = i18next.t(k.STRING1);\nconst MyComponent = () =\u003e {\n  // String 2 will load correctly\n  const string2 = i18next.t(k.STRING2);\n\n  return (\n    \u003cdiv\u003e\n      {string1}\n      {string2}\n    \u003c/div\u003e\n  )\n}\n```\n\n4. **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.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghost---shadow%2Fi18nize-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghost---shadow%2Fi18nize-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghost---shadow%2Fi18nize-react/lists"}