Skip to content

Commit

Permalink
hint override
Browse files Browse the repository at this point in the history
  • Loading branch information
stevencohn committed Nov 19, 2023
1 parent 9756f7e commit c8247d6
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 145 deletions.
29 changes: 20 additions & 9 deletions MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,24 @@ private async void TranslateFile(object sender, EventArgs e)

if (success)
{
SaveTranslations(root, data, inputPath, outputFile);
Log($"Saved {outputFile}{NL}", Color.Blue);
root = ApplyTranslations(root, data, inputPath, outputFile);

var hintCount = 0;
if (hintOverrideBox.Checked && translator.Hints.HasElements)
{
hintCount = ResxProvider.MergeHints(root, translator.Hints);
Log($"Merged {hintCount} hints{NL}", Color.Green);
}

if (data.Count > 0 || hintCount > 0)
{
root.Save(outputFile);
Log($"Saved {outputFile}{NL}", Color.Blue);
}
else
{
Log($"No changes{NL}", Color.Blue);
}
}
}
catch (HttpException exc)
Expand Down Expand Up @@ -396,7 +412,7 @@ private void Log(string message, Color? color = null)
}


private void SaveTranslations(
private XElement ApplyTranslations(
XElement root, List<XElement> data, string inputPath, string outputFile)
{
// add or update changes...
Expand Down Expand Up @@ -462,7 +478,7 @@ private void SaveTranslations(
ResxProvider.SortData(root);
}

root.Save(outputFile);
return root;
}


Expand Down
Loading

0 comments on commit c8247d6

Please sign in to comment.