@@ -78,15 +78,18 @@ def translate_front_matter(front_matter, target_language, input_file):
78
78
if 'title' in front_matter_dict :
79
79
print (f" Translating title: { front_matter_dict ['title' ]} " )
80
80
if not (input_file == 'original/2025-01-11-resume-en.md' and target_language in ['zh' , 'fr' ]):
81
- translated_title = translate_text (front_matter_dict ['title' ], target_language )
82
- if translated_title :
83
- translated_title = translated_title .strip ()
84
- if len (translated_title ) > 300 :
85
- translated_title = translated_title .split ('\n ' )[0 ]
86
- front_matter_dict ['title' ] = translated_title
87
- print (f" Translated title to: { translated_title } " )
81
+ if isinstance (front_matter_dict ['title' ], str ):
82
+ translated_title = translate_text (front_matter_dict ['title' ], target_language )
83
+ if translated_title :
84
+ translated_title = translated_title .strip ()
85
+ if len (translated_title ) > 300 :
86
+ translated_title = translated_title .split ('\n ' )[0 ]
87
+ front_matter_dict ['title' ] = translated_title
88
+ print (f" Translated title to: { translated_title } " )
89
+ else :
90
+ print (f" Title translation failed for: { input_file } " )
88
91
else :
89
- print (f" Title translation failed for: { input_file } " )
92
+ print (f" Title is not a string, skipping translation for: { input_file } " )
90
93
else :
91
94
print (f" Skipping title translation for { input_file } to { target_language } " )
92
95
# Always set lang to target_language
0 commit comments