i18next / i18next-scanner

Scan your code, extract translation keys/values, and merge them into i18n resource files.
http://i18next.github.io/i18next-scanner
MIT License
581 stars 129 forks source link

Are there any plans to support TypeScript? #237

Open KonradLinkowski opened 2 years ago

KonradLinkowski commented 2 years ago

🚀 Feature Proposal

Support for TypeScript files

Motivation

It's impossible to parse .ts and .tsx files now which makes it hard to use with any modern project

Example

It would fix errors like:

i18next-scanner: Unable to parse Trans component from "/path/to/file.tsx"
SyntaxError: Unexpected token (6:10)

It would close #88 and #179

dangyuzheng commented 2 years ago

maybe, you can try converting to js in the transform function of the config.js file

parachvte commented 1 year ago

Use a custom transform, you can easily compile ts/tsx file to ES5/ES6 and extract translations.

mxsxs2 commented 1 year ago

Maybe a bit late. Anyhow, this is what we use to scan tsx files:

rm -rf tmp/i18n && npx tsc --skipLibCheck -target es6 --module esnext --jsx preserve --outDir tmp/i18n && npx i18next-scanner --config i18next-scanner.config.js tmp/i18n/**/*.{js,jsx} && rm -rf tmp/i18n
czabaj commented 1 year ago

Don't know about plans, but this should help parsing ts files https://github.com/i18next/i18next-scanner/issues/88#issuecomment-562446459

capaj commented 2 months ago

https://github.com/lingui/js-lingui supports extraction from ts files no problem, you can try that for i18n