@alauda/doom 0.19.1 → 0.19.2
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 +6 -8
- package/package.json +1 -1
package/lib/cli/translate.js
CHANGED
|
@@ -64,8 +64,8 @@ let openai;
|
|
|
64
64
|
const resolveTerms_ = async () => {
|
|
65
65
|
const terms = await fetchApi('https://gitlab-ce.alauda.cn/alauda-public/product-doc-guide/-/raw/main/terms.yaml', { type: 'text' });
|
|
66
66
|
const parsedTerms = parse(terms);
|
|
67
|
-
return ('- 以下是常见的相关术语词汇对应表(English
|
|
68
|
-
parsedTerms.map(({ en, zh = en }) => ` * ${en}
|
|
67
|
+
return ('- 以下是常见的相关术语词汇对应表(English <-> 中文)\n' +
|
|
68
|
+
parsedTerms.map(({ en, zh = en }) => ` * ${en} <-> ${zh}`).join('\n'));
|
|
69
69
|
};
|
|
70
70
|
let termsCache;
|
|
71
71
|
const resolveTerms = async () => {
|
|
@@ -122,6 +122,7 @@ const limit = pRateLimit({
|
|
|
122
122
|
concurrency: 10,
|
|
123
123
|
});
|
|
124
124
|
const supportedLanguages = SUPPORTED_LANGUAGES.join(', ');
|
|
125
|
+
const shaHash = crypto.createHash('sha256');
|
|
125
126
|
export const translateCommand = new Command('translate')
|
|
126
127
|
.description('Translate the documentation')
|
|
127
128
|
.argument('[root]', 'Root directory of the documentation')
|
|
@@ -194,16 +195,13 @@ export const translateCommand = new Command('translate')
|
|
|
194
195
|
}
|
|
195
196
|
const executor = async () => await Promise.all([...allSourceFilePaths].map(async (sourceFilePath) => {
|
|
196
197
|
const sourceContent = await fs.readFile(sourceFilePath, 'utf-8');
|
|
197
|
-
|
|
198
|
-
|
|
198
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
199
|
+
const { sourceSHA: _sourceSHA, ...sourceFrontmatter } = matter(sourceContent).data;
|
|
199
200
|
if (sourceFrontmatter.i18n?.disableAutoTranslation) {
|
|
200
201
|
allSourceFilePaths.delete(sourceFilePath);
|
|
201
202
|
return;
|
|
202
203
|
}
|
|
203
|
-
const sourceSHA =
|
|
204
|
-
.createHash('sha256')
|
|
205
|
-
.update(sourceContent)
|
|
206
|
-
.digest('hex');
|
|
204
|
+
const sourceSHA = shaHash.update(sourceContent).digest('hex');
|
|
207
205
|
const targetFilePath = sourceFilePath.replace(sourceDir, targetDir);
|
|
208
206
|
let targetContent;
|
|
209
207
|
let targetFrontmatter;
|