@@ -221,7 +221,9 @@ ${html}
221221 console . log ( `Normal HTML elements count: ${ normalElementsCount } ` ) ;
222222
223223 if ( normalElementsCount > 4 ) {
224- throw new Error ( "生成的内容中包含过多原生HTML元素,可能转换失败。" ) ;
224+ throw new Error (
225+ "The generated content contains too many native HTML elements, conversion may have failed."
226+ ) ;
225227 }
226228
227229 return content ;
@@ -231,7 +233,7 @@ ${html}
231233function getRelativeMDXPath ( url : string ) : string {
232234 const match = url . match ( / h t t p s ? : \/ \/ .* ?c p p r e f e r e n c e \. c o m \/ w \/ ( .+ ) \. h t m l $ / ) ;
233235 if ( ! match ) {
234- throw new Error ( `无法从URL解析路径 : ${ url } ` ) ;
236+ throw new Error ( `Unable to parse path from URL : ${ url } ` ) ;
235237 }
236238 const relative = match [ 1 ] ; // "cpp/comments"
237239 return `src/content/docs/${ relative } .mdx` ;
@@ -240,7 +242,7 @@ function getRelativeMDXPath(url: string): string {
240242function getRelativeHTMLPath ( url : string ) : string {
241243 const match = url . match ( / h t t p s ? : \/ \/ .* ?c p p r e f e r e n c e \. c o m \/ w \/ ( .+ ) \. h t m l $ / ) ;
242244 if ( ! match ) {
243- throw new Error ( `无法从URL解析路径 : ${ url } ` ) ;
245+ throw new Error ( `Unable to parse path from URL : ${ url } ` ) ;
244246 }
245247 const relative = match [ 1 ] ; // "cpp/comments"
246248 return `dist/${ relative } /index.html` ;
@@ -262,7 +264,7 @@ title: ${JSON.stringify(title)}
262264description: Auto‑generated from cppreference
263265---\n\n` ;
264266 await fs . writeFile ( filePath , frontmatter + content , "utf8" ) ;
265- console . log ( `写入 ${ filePath } ` ) ;
267+ console . log ( `Written to ${ filePath } ` ) ;
266268}
267269
268270// curl --location --request POST "https://api.imgbb.com/1/upload?expiration=600&key=YOUR_CLIENT_API_KEY" --form "image=R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
@@ -324,18 +326,18 @@ async function createPullRequest(
324326 const webp = visualizeTextDiff ( originalInnerText , newInnerText ) ;
325327 if ( webp ) {
326328 imageUrl = await uploadImageToImgBB ( webp ) ;
327- console . log ( `上传文本差异图像到 ImgBB: ${ imageUrl } ` ) ;
329+ console . log ( `Uploaded text diff image to ImgBB: ${ imageUrl } ` ) ;
328330 }
329331 }
330332
331- const prBody = `> 由 ${ MODEL_NAME } 自 ${ url } 自动迁移
333+ const prBody = `> Automatically migrated from ${ url } by ${ MODEL_NAME }
332334>
333- > 📝 [编辑此页面 ](https://github.com/cppdoc-cc/cppdoc/edit/${ branchName } /${ getRelativeMDXPath ( url ) } )
335+ > 📝 [Edit this page ](https://github.com/cppdoc-cc/cppdoc/edit/${ branchName } /${ getRelativeMDXPath ( url ) } )
334336
335337<small>Close #${ issue . number } </small>
336338
337- ${ imageUrl ? `` : "(无文本差异图像) " }
338- <small>绿色:迁移后词汇出现次数大于迁移前;红色:迁移后词汇出现次数小于迁移前。 </small>
339+ ${ imageUrl ? `` : "(No text diff image) " }
340+ <small>Green: word count increased after migration; Red: word count decreased after migration. </small>
339341` ;
340342
341343 const { execSync } = await import ( "child_process" ) ;
@@ -350,7 +352,7 @@ ${imageUrl ? `` : "(无文本差异图像)"}
350352 execSync ( `git push origin ${ branchName } ` ) ;
351353 } catch ( error ) {
352354 console . error (
353- "Git操作失败 :" ,
355+ "Git operation failed :" ,
354356 error instanceof Error ? error . message : String ( error )
355357 ) ;
356358 throw error ;
@@ -365,7 +367,7 @@ ${imageUrl ? `` : "(无文本差异图像)"}
365367 base : "main" ,
366368 } ) ;
367369
368- console . log ( `创建PR #${ pr . number } ` ) ;
370+ console . log ( `Created PR #${ pr . number } ` ) ;
369371 return pr . number ;
370372}
371373
@@ -388,7 +390,7 @@ async function updateIssue(
388390 owner : REPO_OWNER ,
389391 repo : REPO_NAME ,
390392 issue_number : issue . number ,
391- body : `迁移失败 : ${ message } \n\n已关闭issue。 ` ,
393+ body : `Migration failed : ${ message } \n\nIssue closed. ` ,
392394 } ) ;
393395 await octokit . issues . update ( {
394396 owner : REPO_OWNER ,
@@ -401,13 +403,13 @@ async function updateIssue(
401403 owner : REPO_OWNER ,
402404 repo : REPO_NAME ,
403405 issue_number : issue . number ,
404- body : `迁移完成!已创建PR [#${ prNumber } ].` ,
406+ body : `Migration completed! Created PR [#${ prNumber } ].` ,
405407 } ) ;
406408 }
407409}
408410
409411async function main ( ) {
410- console . log ( "获取带有标签 " , LABEL , "的issue ..." ) ;
412+ console . log ( "Fetching issues with label " , LABEL , "..." ) ;
411413 const { data : issues } = await octokit . issues . listForRepo ( {
412414 owner : REPO_OWNER ,
413415 repo : REPO_NAME ,
@@ -416,48 +418,48 @@ async function main() {
416418 per_page : 50 ,
417419 } ) ;
418420
419- console . log ( `找到 ${ issues . length } 个issue ` ) ;
421+ console . log ( `Found ${ issues . length } issues ` ) ;
420422
421423 for ( const issue of issues ) {
422- console . log ( `处理issue #${ issue . number } : ${ issue . title } ` ) ;
424+ console . log ( `Processing issue #${ issue . number } : ${ issue . title } ` ) ;
423425 try {
424426 if ( hasPRReference ( issue . title ) ) {
425427 continue ;
426428 }
427429
428430 const url = extractLink ( issue . title ) ;
429431 if ( ! url ) {
430- throw new Error ( "标题中未找到有效的cppreference链接 " ) ;
432+ throw new Error ( "No valid cppreference link found in title " ) ;
431433 }
432434
433- console . log ( ` 获取 ${ url } ` ) ;
435+ console . log ( ` Fetching ${ url } ` ) ;
434436 const { html, title, innerText } = await retry (
435437 ( ) => fetchPageContent ( url ) ,
436438 3 ,
437439 2000
438440 ) ;
439441
440- console . log ( ` 转换HTML为MDX ...` ) ;
442+ console . log ( ` Converting HTML to MDX ...` ) ;
441443 const mdx = await retry ( ( ) => convertToMDX ( html , title , url ) , 3 , 2000 ) ;
442444
443445 const filePath = getLocalMDXPath ( url ) ;
444- console . log ( ` 写入 ${ filePath } ` ) ;
446+ console . log ( ` Writing to ${ filePath } ` ) ;
445447 await writeMDXFile ( filePath , mdx , title ) ;
446448
447- console . log ( ` 重新格式化 ...` ) ;
449+ console . log ( ` Re-formatting ...` ) ;
448450 spawnSync ( `npm` , [ "run" , "format" ] , {
449451 stdio : "inherit" ,
450452 shell : true ,
451453 } ) ;
452454
453- console . log ( ` 构建 ...` ) ;
455+ console . log ( ` Building ...` ) ;
454456 const res = spawnSync ( `npm` , [ "run" , "build" ] , {
455457 stdio : "inherit" ,
456458 shell : true ,
457459 } ) ;
458460 if ( res . status !== 0 ) {
459461 throw new Error (
460- "构建失败,可能生成的MDX有问题: " +
462+ "Build failed, possibly due to issues with the generated MDX: " +
461463 res . stderr ?. toString ( ) +
462464 res . stdout ?. toString ( ) +
463465 res . error ?. toString ( ) +
@@ -466,20 +468,20 @@ async function main() {
466468 ) ;
467469 }
468470
469- console . log ( ` 创建PR ...` ) ;
471+ console . log ( ` Creating PR ...` ) ;
470472 const prNumber = await createPullRequest ( issue , filePath , url , innerText ) ;
471473
472- console . log ( ` 更新issue ...` ) ;
474+ console . log ( ` Updating issue ...` ) ;
473475 await updateIssue ( issue , prNumber ) ;
474476
475- console . log ( ` issue #${ issue . number } 完成 ` ) ;
477+ console . log ( ` Issue #${ issue . number } completed ` ) ;
476478 } catch ( error ) {
477- console . error ( ` issue #${ issue . number } 出错 :` , error ) ;
479+ console . error ( ` Issue #${ issue . number } error :` , error ) ;
478480 await updateIssue ( issue , null , error ) ;
479481 }
480482 }
481483
482- console . log ( "全部完成 " ) ;
484+ console . log ( "All completed " ) ;
483485}
484486
485487main ( ) . catch ( ( err ) => {
0 commit comments