i18nize didn't process all files.
dennis-8 opened this issue · 6 comments
Hi,
My React project is using TypeScript.
I noticed that not all .tsx
files were processed by i18nize-react
.
Are there any settings to force to do it?
Also, another thing is: how can we use import
instead of require
in generated files?
Mixing import
and require breaks
my app.
It should process .tsx
files. It is white listed. (https://github.com/Ghost---Shadow/i18nize-react/blob/master/src/walker.js)
Mixing require and import breaks due to this line. (
Line 69 in 7c6b0a5
When I made this I was not aware of dynamic imports
Yes, some tsx
files are parsed, but some are not.
Does it depend on directories number maybe? For example, if there are 10 directories in src/components
, only first N of them will be processed?
And each of the directory has sub-directories.
It walks recursively to an unspecified depth.
These are the only ignore conditions along with ignoring node_modules
const checkIfFileShouldBeIgnored = (fullPath) => {
const hasJsExtension = fullPath.trim().match(/\.[jt]sx?$/);
const isTestFile = fullPath.trim().match(/(test.jsx?|spec.jsx?)/);
return !(hasJsExtension && !isTestFile);
};
Yeah, I noticed that it didn't skip the test files with .ts
or .tsx
extension.
I added skipping for typescript test files in i18nize-react@0.11.0
I need more info regarding what kind of filenames is it skipping.
The only place require
is being used is here.
// If running this script for the second time, it should not
// discard the table generated from the first run
if (fs.existsSync(path.join(path.resolve(inputDir), `${sourceDir}/i18n/english.js`))) {
console.log('english.js exists');
// eslint-disable-next-line
const oldLut = require(path.join(path.resolve(inputDir), `${sourceDir}/i18n/english`));
LutManager.setLut(oldLut);
}
If you are confident that you dont have to run the script a second time, you can just change the require
to an import
.
I hope that solves the problem.
the test name looks like this: App.test.tsx
, index.test.tsx
.
Thank you for your work.