ast-i18n
ast-i18n copied to clipboard
handle params
Options (e.g. for pluralization, or adding context/screenshots for translators) are specified like this:
const thisManyApples = t('{user} ate {count} apples', {count: 3, user: '@sseraphini '})
this could help https://gist.github.com/Munter/87ed1b35cf8a6f7c2e3d26ca7a618cea
we need more AST processing
eslint rules
https://gist.github.com/Munter/87d476c490f6e6debccd02d5acd8e82a
check here https://github.com/oliviertassinari/i18n-extract
I think I almost have something working, but I have a question - why there is babel code that extracts resources and modifies code and there is jacodeshift script that only does the modification?
Great question!
The Babel transformer is based on fbt, it run the transformer just to find all strings values in the code and generate the i18n key value dict, for now it will generate the dict in 18next format. It does not need to modify any code
The jscodeshift will run the same transform, but it will modify the code to the final code with i18n keys
And maybe it would make sense to consolidate the two? For example if jscodeshift at the same time would write to some resource file as it modifies.
not sure if we can do this using jscodeshift as it run all files in parallel, hard to consolidade all strings
but we can try