@alauda/doom 0.19.3 → 0.19.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/translate.js +7 -5
- package/package.json +1 -1
package/lib/cli/translate.js
CHANGED
|
@@ -217,15 +217,17 @@ export const translateCommand = new Command('translate')
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
await limit(async () => {
|
|
220
|
-
const
|
|
221
|
-
|
|
220
|
+
const sourceRelativePath = path.relative(docsDir, sourceFilePath);
|
|
221
|
+
const targetRelativePath = path.relative(docsDir, targetFilePath);
|
|
222
|
+
logger.info(`Translating ${cyan(sourceRelativePath)} to ${cyan(targetRelativePath)}`);
|
|
222
223
|
const isMdx = sourceFilePath.endsWith('.mdx');
|
|
223
224
|
const processor = isMdx ? mdxProcessor : mdProcessor;
|
|
224
225
|
const ast = processor.parse(escapeMarkdownHeadingIds(sourceContent));
|
|
226
|
+
const targetBase = path.dirname(targetFilePath);
|
|
225
227
|
const normalizeImgSrcOptions = {
|
|
226
228
|
localPublicBase: path.resolve(docsDir, 'public'),
|
|
227
229
|
sourceBase: path.dirname(sourceFilePath),
|
|
228
|
-
targetBase
|
|
230
|
+
targetBase,
|
|
229
231
|
translating: { source, target, copy },
|
|
230
232
|
};
|
|
231
233
|
const normalizedSourceContent = processor.stringify({
|
|
@@ -248,9 +250,9 @@ export const translateCommand = new Command('translate')
|
|
|
248
250
|
newFrontmatter.title = sourceFrontmatter.i18n.title[target];
|
|
249
251
|
}
|
|
250
252
|
targetContent = matter.stringify(content.startsWith('\n') ? content : '\n' + content, newFrontmatter);
|
|
251
|
-
await fs.mkdir(
|
|
253
|
+
await fs.mkdir(targetBase, { recursive: true });
|
|
252
254
|
await fs.writeFile(targetFilePath, targetContent);
|
|
253
|
-
logger.info(`${cyan(
|
|
255
|
+
logger.info(`${cyan(sourceRelativePath)} translated to ${cyan(targetRelativePath)}`);
|
|
254
256
|
allSourceFilePaths.delete(sourceFilePath);
|
|
255
257
|
});
|
|
256
258
|
}));
|