@@ -32,7 +32,7 @@ const MAXLEN = Number(process.env.MAX_LEN) || 3000;
32
32
33
33
// change to true to avoid calling openai api, useful for troubleshooting
34
34
// chunking logic
35
- const troubleshoot = false ;
35
+ const troubleshoot = true ;
36
36
37
37
// Centralized logging to prevent duplicate messages
38
38
const errorMessages = new Set ( ) ;
@@ -80,7 +80,7 @@ async function translate(language: string, filePath: string): Promise<void> {
80
80
// Use the provided file path directly without modification
81
81
const input_path = filePath ;
82
82
83
- assistant = await createAssistant ( language , ai as any ) ;
83
+ if ( ! troubleshoot ) assistant = await createAssistant ( language , ai as any ) ;
84
84
85
85
// Generate output path by replacing "/en/" with "/cn/" in the path
86
86
const output_path = filePath . replace (
@@ -91,7 +91,7 @@ async function translate(language: string, filePath: string): Promise<void> {
91
91
const translated : string = await recursivelyTranslate (
92
92
language ,
93
93
input_path ,
94
- assistant . id
94
+ troubleshoot ? 0 : assistant . id
95
95
) ;
96
96
97
97
// Ensure directory exists
@@ -287,15 +287,6 @@ async function recursivelyTranslate(
287
287
parser . on ( "opentag" , node => {
288
288
currentDepth ++ ;
289
289
290
- // If we're at depth 2, this is the start of a new segment.
291
- if (
292
- node . name == "SCHEME" ||
293
- node . name == "SCHEMEINLINE" ||
294
- parser . _parser . tag === "SCHEME" ||
295
- parser . _parser . tag === "SCHEMEINLINE"
296
- )
297
- return ;
298
-
299
290
if ( currentDepth === 2 || isRecording ) {
300
291
isRecording = true ;
301
292
currentSegment += `<${ node . name } ${ formatAttributes ( node . attributes ) } >` ;
@@ -310,13 +301,6 @@ async function recursivelyTranslate(
310
301
parser . on ( "text" , text => {
311
302
text = strongEscapeXML ( text ) ;
312
303
313
- // ignore all scheme contents
314
- if (
315
- parser . _parser . tag == "SCHEME" ||
316
- parser . _parser . tag == "SCHEMEINLINE"
317
- )
318
- return ;
319
-
320
304
if ( isRecording ) {
321
305
currentSegment += text ;
322
306
} else {
@@ -331,13 +315,7 @@ async function recursivelyTranslate(
331
315
} ) ;
332
316
333
317
parser . on ( "closetag" , tagName => {
334
- if (
335
- tagName !== "SCHEME" &&
336
- tagName !== "SCHEMEINLINE" &&
337
- parser . _parser . tag !== "SCHEME" &&
338
- parser . _parser . tag !== "SCHEMEINLINE" &&
339
- isRecording
340
- ) {
318
+ if ( isRecording ) {
341
319
currentSegment += `</${ tagName } >` ;
342
320
}
343
321
0 commit comments