@@ -109,15 +109,17 @@ func runDocsI18N(ctx context.Context, cfg runConfig, files []string, newTranslat
109109 }
110110 totalFiles := len (ordered )
111111 preSkipped := 0
112+ prePostprocessFiles := []string {}
112113 if cfg .mode == "doc" && ! cfg .overwrite {
113- filtered , skipped , err := filterDocQueue (resolvedDocsRoot , cfg .targetLang , ordered )
114+ filtered , skipped , existingOutputs , err := filterDocQueue (resolvedDocsRoot , cfg .targetLang , ordered , cfg . maxFiles )
114115 if err != nil {
115116 return err
116117 }
117118 ordered = filtered
118119 preSkipped = skipped
120+ prePostprocessFiles = append (prePostprocessFiles , existingOutputs ... )
119121 }
120- if cfg .maxFiles > 0 && cfg .maxFiles < len (ordered ) {
122+ if ( cfg . mode != "doc" || cfg . overwrite ) && cfg .maxFiles > 0 && cfg .maxFiles < len (ordered ) {
121123 ordered = ordered [:cfg .maxFiles ]
122124 }
123125
@@ -130,7 +132,7 @@ func runDocsI18N(ctx context.Context, cfg runConfig, files []string, newTranslat
130132 start := time .Now ()
131133 processed := 0
132134 skipped := 0
133- localizedFiles := []string {}
135+ localizedFiles := append ( []string {}, prePostprocessFiles ... )
134136 var translationErr error
135137
136138 log .Printf ("docs-i18n: mode=%s total=%d pending=%d pre_skipped=%d overwrite=%t thinking=%s parallel=%d" , cfg .mode , totalFiles , len (ordered ), preSkipped , cfg .overwrite , cfg .thinking , parallel )
@@ -217,6 +219,9 @@ func runDocSequential(ctx context.Context, ordered []string, translator docsTran
217219 }
218220 if skip {
219221 skipped ++
222+ if outputPath != "" {
223+ outputs = append (outputs , outputPath )
224+ }
220225 log .Printf ("docs-i18n: [%d/%d] skipped %s (%s)" , index + 1 , len (ordered ), relPath , time .Since (start ).Round (time .Millisecond ))
221226 } else {
222227 processed ++
@@ -294,6 +299,9 @@ func runDocParallel(ctx context.Context, ordered []string, docsRoot, srcLang, tg
294299 }
295300 if result .skipped {
296301 skipped ++
302+ if result .output != "" {
303+ outputs = append (outputs , result .output )
304+ }
297305 log .Printf ("docs-i18n: [w* %d/%d] skipped %s (%s)" , result .index , len (ordered ), result .rel , result .duration .Round (time .Millisecond ))
298306 } else if result .err != nil {
299307 log .Printf ("docs-i18n: [w* %d/%d] failed %s (%s): %v" , result .index , len (ordered ), result .rel , result .duration .Round (time .Millisecond ), result .err )
@@ -339,29 +347,40 @@ func resolveRelPath(docsRoot, file string) string {
339347 return relPath
340348}
341349
342- func filterDocQueue (docsRoot , targetLang string , ordered []string ) ([]string , int , error ) {
350+ func filterDocQueue (docsRoot , targetLang string , ordered []string , maxFiles int ) ([]string , int , [] string , error ) {
343351 pending := make ([]string , 0 , len (ordered ))
352+ existingOutputs := []string {}
344353 skipped := 0
345354 for _ , file := range ordered {
346355 absPath , relPath , err := resolveDocsPath (docsRoot , file )
347356 if err != nil {
348- return nil , skipped , err
357+ return nil , skipped , nil , err
349358 }
350359 content , err := os .ReadFile (absPath )
351360 if err != nil {
352- return nil , skipped , err
361+ return nil , skipped , nil , err
353362 }
354363 sourceHash := hashBytes (content )
355364 outputPath := filepath .Join (docsRoot , targetLang , relPath )
356- skip , err := shouldSkipDoc (outputPath , sourceHash )
365+ status , err := classifyDocOutput (outputPath , sourceHash , targetLang )
357366 if err != nil {
358- return nil , skipped , err
367+ return nil , skipped , nil , err
359368 }
360- if skip {
369+ switch status {
370+ case docOutputReady :
361371 skipped ++
362- continue
372+ case docOutputNeedsPostprocess :
373+ if maxFiles > 0 && len (pending )+ len (existingOutputs ) >= maxFiles {
374+ continue
375+ }
376+ skipped ++
377+ existingOutputs = append (existingOutputs , outputPath )
378+ case docOutputNeedsTranslation :
379+ if maxFiles > 0 && len (pending )+ len (existingOutputs ) >= maxFiles {
380+ continue
381+ }
382+ pending = append (pending , file )
363383 }
364- pending = append (pending , file )
365384 }
366- return pending , skipped , nil
385+ return pending , skipped , existingOutputs , nil
367386}
0 commit comments