{"id":13533156,"url":"https://github.com/sibelius/ast-i18n","last_synced_at":"2025-08-02T10:10:07.358Z","repository":{"id":34100828,"uuid":"169907573","full_name":"sibelius/ast-i18n","owner":"sibelius","description":"Easily migrate your existing React codebase to use i18n","archived":false,"fork":false,"pushed_at":"2024-06-18T06:17:39.000Z","size":402,"stargazers_count":228,"open_issues_count":9,"forks_count":18,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-07-29T16:27:33.786Z","etag":null,"topics":["ast","codemod","i18n","react"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/sibelius.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-02-09T19:57:56.000Z","updated_at":"2025-06-03T21:15:01.000Z","dependencies_parsed_at":"2024-06-05T15:15:29.705Z","dependency_job_id":"69d10a49-c835-4e14-bcdc-b7df57c89140","html_url":"https://github.com/sibelius/ast-i18n","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sibelius/ast-i18n","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibelius%2Fast-i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibelius%2Fast-i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibelius%2Fast-i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibelius%2Fast-i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sibelius","download_url":"https://codeload.github.com/sibelius/ast-i18n/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sibelius%2Fast-i18n/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268370117,"owners_count":24239764,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ast","codemod","i18n","react"],"created_at":"2024-08-01T07:01:17.080Z","updated_at":"2025-08-02T10:10:07.331Z","avatar_url":"https://github.com/sibelius.png","language":"TypeScript","readme":"# AST i18n [![Build Status](https://travis-ci.org/sibelius/ast-i18n.svg?branch=master)](https://travis-ci.org/sibelius/ast-i18n)\n\nThe objective of this tool is to make easy to migrate an existing codebase to use i18n\n\n## How it works\n- it gets a list of files from the command line\n- it runs a babel plugin transform to find all string inside JSXText\n- it generates a stable key for the extracted strings\n- it generates i18n files format based on this map\n- it modify your existing code to use i18n library of your preference\n\n## Example\n\nBefore this transform\n```jsx\nimport React from 'react';\n\nconst Simple = () =\u003e (\n  \u003cspan\u003eMy simple text\u003c/span\u003e\n);\n```\n\nAfter this transform\n```jsx\nimport React from 'react';\nimport { withTranslation } from 'react-i18next'\n\nconst Simple = ({ t }) =\u003e (\n  \u003cspan\u003e{t('my_simple_text')}\u003c/span\u003e\n);\n```\n\n## Usage of string extractor\n```bash\nyarn start --src=myapp/src\n```\n\n- It will generate a resource.jsx file, like the below:\n```jsx\nexport default {\n  translation: {\n   'ok': `ok`,\n   'cancelar': `cancelar`,\n   'continuar': `continuar`,\n   'salvar': `salvar`,\n   'endereco': `endereço:`,\n   'troca_de_senha': `troca de senha`,\n   'dados_pessoais': `dados pessoais`,\n   [key]: 'value',\n  }\n}\n```\n\n### How to use resource with react-i18next?\n- rename resource.tsx to your main language, like en.ts\n- create other resource languages based on the generated one\n\n```jsx\nimport en from './en';\n\ni18n.use(LanguageDetector).init({\n  resources: {\n    en,\n  },\n  fallbackLng: 'ptBR',\n  debug: false,\n\n  interpolation: {\n    escapeValue: false, // not needed for react!!\n    formatSeparator: ',',\n  },\n\n  react: {\n    wait: true,\n  },\n});\n```\n\n## Usage of i18n codemod\n```bash\nnpm i -g jscodeshift\n\njscodeshift -t src/i18nTransformerCodemod.ts PATH_TO_FILES\n```\n\n## How to customize blacklist\nUse ast.config.js to customize blacklist for jsx attribute name and call expression calle\n\n```jsx\nmodule.exports = {\n  blackListJsxAttributeName: [\n    'type',\n    'id',\n    'name',\n    'children',\n    'labelKey',\n    'valueKey',\n    'labelValue',\n    'className',\n    'color',\n    'key',\n    'size',\n    'charSet',\n    'content',\n  ],\n  blackListCallExpressionCalle: [\n    't',\n    '_interopRequireDefault',\n    'require',\n    'routeTo',\n    'format',\n    'importScripts',\n    'buildPath',\n    'createLoadable',\n    'import',\n    'setFieldValue',\n  ],\n};\n```\n","funding_links":[],"categories":["TypeScript","Frameworks"],"sub_categories":["React.js"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsibelius%2Fast-i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsibelius%2Fast-i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsibelius%2Fast-i18n/lists"}