@@ -89,6 +89,7 @@ class FileStats:
8989 total_in_file : int = 0
9090 untranslated : int = 0
9191 translated_in_file : int = 0
92+ fuzzy : int = 0
9293
9394
9495class TranslationService :
@@ -515,22 +516,34 @@ def _show_mode_info(self, total_entries: int):
515516 def _show_translation_summary (self , scan_results , languages ):
516517 """Show summary of files to translate."""
517518 logging .info ("=" * 70 )
518- logging .info ("TRANSLATION OVERVIEW" )
519+ if self .config .flags .fix_fuzzy :
520+ logging .info ("FUZZY FIX OVERVIEW" )
521+ else :
522+ logging .info ("TRANSLATION OVERVIEW" )
519523 logging .info ("=" * 70 )
520524 logging .info ("SCAN RESULTS:" )
521525 logging .info (" Total PO files found: %d" , scan_results ['files_scanned' ])
522526 files_matched = len (scan_results ['files_to_process' ]) + len (scan_results ['skipped_files' ])
523527 logging .info (" Files matching languages: %d" , files_matched )
524528 logging .info (" Files with language mismatch: %d" , scan_results ['language_mismatch_files' ])
525529 logging .info ("" )
526- logging .info ("TRANSLATION STATUS:" )
527- logging .info (" Files needing translation: %d" , len (scan_results ['files_to_process' ]))
528- logging .info (" Files already fully translated: %d" , len (scan_results ['skipped_files' ]))
529- logging .info ("" )
530- logging .info ("ENTRY STATISTICS:" )
531- logging .info (" Total entries in all files: %d" , scan_results ['total_entries_in_all_files' ])
532- logging .info (" Already translated entries: %d" , scan_results ['total_translated_in_all_files' ])
533- logging .info (" Entries to translate: %d" , scan_results ['total_entries' ])
530+ if self .config .flags .fix_fuzzy :
531+ logging .info ("FUZZY STATUS:" )
532+ logging .info (" Files with fuzzy entries: %d" , len (scan_results ['files_to_process' ]))
533+ logging .info (" Files without fuzzy entries: %d" , len (scan_results ['skipped_files' ]))
534+ logging .info ("" )
535+ logging .info ("ENTRY STATISTICS:" )
536+ logging .info (" Total entries in all files: %d" , scan_results ['total_entries_in_all_files' ])
537+ logging .info (" Fuzzy entries to fix: %d" , scan_results ['total_entries' ])
538+ else :
539+ logging .info ("TRANSLATION STATUS:" )
540+ logging .info (" Files needing translation: %d" , len (scan_results ['files_to_process' ]))
541+ logging .info (" Files already fully translated: %d" , len (scan_results ['skipped_files' ]))
542+ logging .info ("" )
543+ logging .info ("ENTRY STATISTICS:" )
544+ logging .info (" Total entries in all files: %d" , scan_results ['total_entries_in_all_files' ])
545+ logging .info (" Already translated entries: %d" , scan_results ['total_translated_in_all_files' ])
546+ logging .info (" Entries to translate: %d" , scan_results ['total_entries' ])
534547
535548 if scan_results ['total_entries_in_all_files' ] > 0 :
536549 completion_percent = (
@@ -548,6 +561,11 @@ def _analyze_po_file(self, po_file):
548561 stats .total_in_file = len ([e for e in po_file if e .msgid ])
549562 stats .untranslated = len ([e for e in po_file if is_entry_untranslated (e )])
550563 stats .translated_in_file = stats .total_in_file - stats .untranslated
564+ # Also count fuzzy entries when fix_fuzzy is enabled
565+ if self .config .flags .fix_fuzzy :
566+ stats .fuzzy = len ([e for e in po_file if 'fuzzy' in e .flags ])
567+ else :
568+ stats .fuzzy = 0
551569 return stats
552570
553571 def _scan_po_files (self , input_folder : str , languages : List [str ], gitignore_parser ):
@@ -569,11 +587,18 @@ def _scan_po_files(self, input_folder: str, languages: List[str], gitignore_pars
569587 results .total_entries_in_all_files += stats .total_in_file
570588 results .total_translated_in_all_files += stats .translated_in_file
571589
572- if stats .untranslated > 0 :
573- results .files_to_process .append ((po_file_path , po_file_result , stats .untranslated ))
574- results .total_entries += stats .untranslated
575- logging .debug ("File %s: %d/%d entries need translation" ,
576- po_file_path , stats .untranslated , stats .total_in_file )
590+ # Include files with fuzzy entries when fix_fuzzy is enabled
591+ needs_processing = stats .untranslated > 0 or (self .config .flags .fix_fuzzy and stats .fuzzy > 0 )
592+
593+ if needs_processing :
594+ entries_to_process = stats .untranslated if not self .config .flags .fix_fuzzy else stats .fuzzy
595+ results .files_to_process .append ((po_file_path , po_file_result , entries_to_process ))
596+ results .total_entries += entries_to_process
597+ if self .config .flags .fix_fuzzy and stats .fuzzy > 0 :
598+ logging .debug ("File %s: %d fuzzy entries to fix" , po_file_path , stats .fuzzy )
599+ else :
600+ logging .debug ("File %s: %d/%d entries need translation" ,
601+ po_file_path , stats .untranslated , stats .total_in_file )
577602 else :
578603 results .skipped_files .append (po_file_path )
579604 logging .debug ("Skipping fully translated file: %s" , po_file_path )
0 commit comments