@@ -352,6 +352,31 @@ def check_spelling(self, spelling: str, checkers: list[SpellChecker]) -> list[Po
352352 )
353353 return errors
354354
355+ def check_fuzzy_string (self ) -> list [PoReport ]:
356+ """Check if message is marked as fuzzy.
357+
358+ Return a list with errors detected.
359+ """
360+ if not self .fuzzy :
361+ return []
362+ errors : list [PoReport ] = []
363+ # Report fuzzy strings (skip header entries with empty msgid)
364+ for mid , mstr in self .messages :
365+ if mid : # Skip header entries (empty msgid)
366+ errors .append (
367+ PoReport (
368+ "fuzzy string found" ,
369+ "fuzzy" ,
370+ self .filename ,
371+ self .line ,
372+ mid ,
373+ mstr ,
374+ fuzzy = True ,
375+ ),
376+ )
377+ break
378+ return errors
379+
355380
356381class Checker :
357382 """Messages checker."""
@@ -596,6 +621,8 @@ def check_msg(
596621 if mid and mstr :
597622 reports .append (PoReport (mstr , "extract" ))
598623 else :
624+ if self .checks ["fuzzy" ]:
625+ reports += msg .check_fuzzy_string ()
599626 if self .checks ["lines" ]:
600627 reports += msg .check_lines ()
601628 if self .checks ["punct" ]:
@@ -629,7 +656,7 @@ def check_pofile(self, po_file: PoFile) -> list[PoReport]:
629656
630657 return reports
631658
632- def check_file (self , filename : str ) -> PoFileReport :
659+ def check_file (self , filename : str ) -> PoFileReport :
633660 """Check compilation and translations in a PO file."""
634661 po_file = PoFile (filename )
635662 report = PoFileReport (po_file .filename )
@@ -660,11 +687,13 @@ def check_files(self, files: list[str]) -> list[PoFileReport]:
660687 for path in files :
661688 if Path (path ).is_dir ():
662689 for root , _ , filenames in os .walk (path ):
663- result .extend ([
664- self .check_file (str (Path (root ) / filename ))
665- for filename in filenames
666- if filename .endswith (".po" )
667- ])
690+ result .extend (
691+ [
692+ self .check_file (str (Path (root ) / filename ))
693+ for filename in filenames
694+ if filename .endswith (".po" )
695+ ],
696+ )
668697 else :
669698 result .append (self .check_file (path ))
670699 return result
0 commit comments