Skip to content

Commit 6826c85

Browse files
Handle invalid po files during AI translation
1 parent d1a83ed commit 6826c85

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/MarkdownLocalize.CLI/Program.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,15 @@ private void GeneratePOT(string inputMarkdown, string outputPOT)
313313
private void AITranslate(string poFile, string outputFile, string targetLanguage)
314314
{
315315
string pot = File.ReadAllText(poFile);
316-
var existingCatalog = File.Exists(outputFile) ? POT.Load(File.ReadAllText(outputFile)) : null;
316+
POCatalog existingCatalog = null;
317+
try
318+
{
319+
existingCatalog = File.Exists(outputFile) ? POT.Load(File.ReadAllText(outputFile)) : null;
320+
}
321+
catch (Exception ex)
322+
{
323+
Log($"Error loading existing catalog: {ex.Message}. Will ignore existing translations.");
324+
}
317325
var catalog = POT.Load(pot);
318326
Translator ModelTranslator = null;
319327

0 commit comments

Comments
 (0)