Skip to content

Commit

Permalink
File Checking in estimate XLIFF translation action
Browse files Browse the repository at this point in the history
  • Loading branch information
RiabushenkoA committed Feb 6, 2025
1 parent 65e0e1b commit 47dfb2f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Apps.Widn/Actions/QualityActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ private List<TranslationUnit> ExtractSegmentsFromXliff(Stream inputStream)
{
var xliffDocument = XDocument.Load(reader);

if (xliffDocument.Root == null || xliffDocument.Root.Name.LocalName.ToLower() != "xliff")
{
throw new PluginMisconfigurationException("Invalid file format. The provided file does not appear to be a valid XLIFF file. Please check the input file");
}

XNamespace ns = xliffDocument.Root.GetDefaultNamespace();

var transUnits = xliffDocument.Descendants(ns + "trans-unit");
Expand Down
2 changes: 1 addition & 1 deletion Apps.Widn/Apps.Widn.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<Product>Widn</Product>
<Description>Accurate translations, preserving meaning and nuance across +20 language pairs and various domains.</Description>
<Version>1.0.14</Version>
<Version>1.0.15</Version>
<AssemblyName>Apps.Widn</AssemblyName>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion Tests.Widn/TranslateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task EvaluateQuality_ReturnsValues()
};
var input2 = new QualityEvaluateRequest
{
ReferenceText = "Hi"
ReferenceText = "Hello"
};
var result = await action.EvaluateQuality(input1, input2);
Assert.IsNotNull(result);
Expand Down

0 comments on commit 47dfb2f

Please sign in to comment.