Fixed challenge completion text on Polish.

This commit is contained in:
MaikyM 2019-12-07 19:09:31 -06:00
parent 8952227524
commit 02c41342d1
3 changed files with 52 additions and 3 deletions

View File

@ -100,7 +100,7 @@
<HintPath>..\packages\System.Numerics.Vectors.4.6.0-preview5.19224.8\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.6.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.7.0-preview3.19551.4\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.7.0\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.Web" />

View File

@ -1,7 +1,8 @@
using FModel.Methods.Utilities;
using FModel.Methods.Utilities;
using Newtonsoft.Json.Linq;
using System;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Media;
using FProp = FModel.Properties.Settings;
@ -130,6 +131,54 @@ namespace FModel.Methods.Assets.IconCreator.ChallengeID
if (all.Contains("</>")) { all = all.Replace("</>", "</text>"); }
if (any.Contains("</>")) { any = any.Replace("</>", "</text>"); }
// Polish
if (all.Contains("|plural"))
{
int indexStart = all.IndexOf("|plural(") + 8;
int indexEnd = all.IndexOf(")", indexStart);
string extractDatas = all.Substring(indexStart, indexEnd - indexStart);
// one = 1, few >= 2 and <= 4, many > 4, other = ??
System.Collections.Generic.Dictionary<string, string> various = extractDatas.Split(',').Select(x => x.Split('=')).Where(x => x.Length == 2).ToDictionary(x => x[0], x => x[1]);
if (various != null && various.Any())
{
int compCount = int.Parse(completionCount);
string variousText = various.ContainsKey("other") ? various["other"] : "";
if (compCount == 1 && various.ContainsKey("one"))
variousText = various["one"];
else if (compCount >= 2 && compCount <= 4 && various.ContainsKey("few"))
variousText = various["few"];
else if (compCount > 4 && various.ContainsKey("many"))
variousText = various["many"];
all = all.Replace($"|plural({extractDatas})", "").Replace("{0} {0}", "{0} " + variousText);
}
}
// Polish
if (any.Contains("|plural"))
{
int indexStart = any.IndexOf("|plural(") + 8;
int indexEnd = any.IndexOf(")", indexStart);
string extractDatas = any.Substring(indexStart, indexEnd - indexStart);
// one = 1, few >= 2 and <= 4, many > 4, other = ??
System.Collections.Generic.Dictionary<string, string> various = extractDatas.Split(',').Select(x => x.Split('=')).Where(x => x.Length == 2).ToDictionary(x => x[0], x => x[1]);
if (various != null && various.Any())
{
int compCount = int.Parse(completionCount);
string variousText = various.ContainsKey("other") ? various["other"] : "";
if (compCount == 1 && various.ContainsKey("one"))
variousText = various["one"];
else if (compCount >= 2 && compCount <= 4 && various.ContainsKey("few"))
variousText = various["few"];
else if (compCount > 4 && various.ContainsKey("many"))
variousText = various["many"];
any = any.Replace($"|plural({extractDatas})", "").Replace("{0} {0}", "{0} " + variousText);
}
}
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(all);
if (doc.DocumentNode.InnerText.Contains(" {0}")) //avoid white space

View File

@ -10,7 +10,7 @@
<package id="System.Buffers" version="4.5.0" targetFramework="net472" />
<package id="System.Memory" version="4.5.3" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.6.0-preview5.19224.8" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.0-preview3.19551.4" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.0" targetFramework="net472" />
<package id="WPFThemes.DarkBlend" version="1.0.8" targetFramework="net472" />
<package id="WriteableBitmapEx" version="1.6.3" targetFramework="net472" />
</packages>