From 8259f790d75ca5c18ef8e3d56824b8f86dde1eff Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Sun, 22 Dec 2024 13:19:10 -0600 Subject: [PATCH] misc: Cleanup locale validator --- .../LocaleValidationTask.cs | 21 ++++++++----------- src/Ryujinx/Assets/locales.json | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/Ryujinx.BuildValidationTasks/LocaleValidationTask.cs b/src/Ryujinx.BuildValidationTasks/LocaleValidationTask.cs index 183228fdd..6dc3d8aa8 100644 --- a/src/Ryujinx.BuildValidationTasks/LocaleValidationTask.cs +++ b/src/Ryujinx.BuildValidationTasks/LocaleValidationTask.cs @@ -14,20 +14,20 @@ namespace Ryujinx.BuildValidationTasks { 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 - 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 { - path = path.Split(new string[] { "src" }, StringSplitOptions.None)[0]; - path = new FileInfo(path).Directory.GetDirectories("src")[0].GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName; + 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; } string data; - using (StreamReader sr = new StreamReader(path)) + using (StreamReader sr = new(path)) { data = sr.ReadToEnd(); } @@ -38,13 +38,10 @@ namespace Ryujinx.BuildValidationTasks { 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(language, ""); - Log.LogMessage(MessageImportance.High, $"Added {{{language}}} to Locale {{{locale.ID}}}"); - } + locale.Translations.Add(langCode, string.Empty); + Log.LogMessage(MessageImportance.High, $"Added '{langCode}' to Locale '{locale.ID}'"); } 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); - using (StreamWriter sw = new StreamWriter(path)) + using (StreamWriter sw = new(path)) { sw.Write(jsonString); } diff --git a/src/Ryujinx/Assets/locales.json b/src/Ryujinx/Assets/locales.json index 167accd34..33dd61d42 100644 --- a/src/Ryujinx/Assets/locales.json +++ b/src/Ryujinx/Assets/locales.json @@ -21574,4 +21574,4 @@ } } ] -} +} \ No newline at end of file