mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2025-01-09 22:52:00 +00:00
misc: Cleanup locale validator
This commit is contained in:
parent
1ea345faa7
commit
8259f790d7
2 changed files with 10 additions and 13 deletions
|
@ -14,20 +14,20 @@ namespace Ryujinx.BuildValidationTasks
|
||||||
{
|
{
|
||||||
string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
||||||
|
|
||||||
if (path.Split(new string[] { "src" }, StringSplitOptions.None).Length == 1 )
|
if (path.Split(["src"], StringSplitOptions.None).Length == 1)
|
||||||
{
|
{
|
||||||
//i assume that we are in a build directory in the solution dir
|
//i assume that we are in a build directory in the solution dir
|
||||||
path = new FileInfo(path).Directory.Parent.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName;
|
path = new FileInfo(path).Directory!.Parent!.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
path = path.Split(new string[] { "src" }, StringSplitOptions.None)[0];
|
path = path.Split(["src"], StringSplitOptions.None)[0];
|
||||||
path = new FileInfo(path).Directory.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName;
|
path = new FileInfo(path).Directory!.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
string data;
|
string data;
|
||||||
|
|
||||||
using (StreamReader sr = new StreamReader(path))
|
using (StreamReader sr = new(path))
|
||||||
{
|
{
|
||||||
data = sr.ReadToEnd();
|
data = sr.ReadToEnd();
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,10 @@ namespace Ryujinx.BuildValidationTasks
|
||||||
{
|
{
|
||||||
LocalesEntry locale = json.Locales[i];
|
LocalesEntry locale = json.Locales[i];
|
||||||
|
|
||||||
foreach (string language in json.Languages)
|
foreach (string langCode in json.Languages.Where(it => !locale.Translations.ContainsKey(it)))
|
||||||
{
|
{
|
||||||
if (!locale.Translations.ContainsKey(language))
|
locale.Translations.Add(langCode, string.Empty);
|
||||||
{
|
Log.LogMessage(MessageImportance.High, $"Added '{langCode}' to Locale '{locale.ID}'");
|
||||||
locale.Translations.Add(language, "");
|
|
||||||
Log.LogMessage(MessageImportance.High, $"Added {{{language}}} to Locale {{{locale.ID}}}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
locale.Translations = locale.Translations.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value);
|
locale.Translations = locale.Translations.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value);
|
||||||
|
@ -53,7 +50,7 @@ namespace Ryujinx.BuildValidationTasks
|
||||||
|
|
||||||
string jsonString = JsonConvert.SerializeObject(json, Formatting.Indented);
|
string jsonString = JsonConvert.SerializeObject(json, Formatting.Indented);
|
||||||
|
|
||||||
using (StreamWriter sw = new StreamWriter(path))
|
using (StreamWriter sw = new(path))
|
||||||
{
|
{
|
||||||
sw.Write(jsonString);
|
sw.Write(jsonString);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue