@@ -30,28 +30,28 @@ def disable_fuzzy_translations(po_file_path):
30
30
# Read the file content
31
31
with open (po_file_path , 'r' , encoding = 'utf-8' ) as file :
32
32
content = file .read ()
33
-
33
+
34
34
# Remove fuzzy markers from the content
35
35
content = content .replace ('#, fuzzy\n ' , '' )
36
-
36
+
37
37
# Write the updated content back to the file
38
38
with open (po_file_path , 'w' , encoding = 'utf-8' ) as file :
39
39
file .write (content )
40
-
40
+
41
41
# Load the .po file and remove fuzzy flags from entries
42
42
po_file = polib .pofile (po_file_path )
43
43
fuzzy_entries = [entry for entry in po_file if 'fuzzy' in entry .flags ]
44
44
for entry in fuzzy_entries :
45
45
entry .flags .remove ('fuzzy' )
46
-
46
+
47
47
# Remove 'Fuzzy' from the metadata if present
48
48
if po_file .metadata :
49
49
po_file .metadata .pop ('Fuzzy' , None )
50
-
50
+
51
51
# Save the updated .po file
52
52
po_file .save (po_file_path )
53
53
logging .info ("Fuzzy translations disabled in file: %s" , po_file_path )
54
-
54
+
55
55
except Exception as e :
56
56
logging .error ("Error while disabling fuzzy translations in file %s: %s" , po_file_path , e )
57
57
@@ -76,7 +76,7 @@ def log_translation_status(po_file_path, original_texts, translations):
76
76
"""Logs the status of translations for a .po file."""
77
77
total = len (original_texts )
78
78
translated = sum (1 for t in translations if t )
79
-
79
+
80
80
# Log a warning if there are untranslated texts
81
81
if translated < total :
82
82
logging .warning (
@@ -233,7 +233,7 @@ def get_translation_prompt(target_language, is_bulk):
233
233
@retry (stop = stop_after_attempt (3 ), wait = wait_fixed (2 ))
234
234
def perform_translation (self , texts , target_language , is_bulk = False ):
235
235
"""Performs the actual translation using the OpenAI API."""
236
- logging .info ( f "Performing translation to: { target_language } " ) # Log the target language
236
+ logging .debug ( "Performing translation to: %s" , target_language ) # Log the target language
237
237
prompt = self .get_translation_prompt (target_language , is_bulk )
238
238
message = {
239
239
"role" : "user" ,
0 commit comments