This repository contains examples on how to transform your React code to replace hard coded strings with translation functions. The setup can be seen as a starting point for building your own transformers to scaffold your react-i18next or react-intl internationalization. These examples are used in the blog post Scaffolding your internatlization in React with automation.
The examples use ts-morph but this can be replaced by either working directly with the Typscript compiler API or using another AST parser.
There are more transformations than can be useful like automatically replacing any alt tags text with a translation function. The transform function can be extended to handle more automatic transformations.
The transformers can be found in the src/transformers folder, and the tests in the tests folder.
Install all required dependencies:
pnpm installThen run all the tests:
pnpm test