Unified locales #391

Merged
LotP1 merged 25 commits from unified-locales into master 2024-12-20 19:27:11 +00:00
7 changed files with 660 additions and 611 deletions
Showing only changes of commit 798082c785 - Show all commits

View File

@ -10,6 +10,9 @@
<PackageVersion Include="Avalonia.Markup.Xaml.Loader" Version="11.0.10" />
<PackageVersion Include="Avalonia.Svg" Version="11.0.0.18" />
<PackageVersion Include="Avalonia.Svg.Skia" Version="11.0.0.18" />
<PackageVersion Include="Microsoft.Build.Framework" Version="17.11.4" />
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="17.12.6" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Projektanker.Icons.Avalonia" Version="9.4.0" />
<PackageVersion Include="Projektanker.Icons.Avalonia.FontAwesome" Version="9.4.0"/>
<PackageVersion Include="Projektanker.Icons.Avalonia.MaterialDesign" Version="9.4.0"/>

View File

@ -90,6 +90,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.github/workflows/build.yml = .github/workflows/build.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ryujinx.BuildValidationTasks", "src\Ryujinx.BuildValidationTasks\Ryujinx.BuildValidationTasks.csproj", "{4A89A234-4F19-497D-A576-DDE8CDFC5B22}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -252,6 +254,10 @@ Global
{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B575BCDE-2FD8-4A5D-8756-31CDD7FE81F0}.Release|Any CPU.Build.0 = Release|Any CPU
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A89A234-4F19-497D-A576-DDE8CDFC5B22}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,67 @@
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
using System;
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
using Microsoft.Build.Utilities;
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
using System.Collections.Generic;
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
using System.Linq;
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
using System.IO;
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
using Newtonsoft.Json;
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
using Microsoft.Build.Framework;
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
namespace Ryujinx.BuildValidationTasks
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
{
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
public class LocaleValidationTask : Task
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
{
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
public override bool Execute()
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
{
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
path = new FileInfo(path).Directory.Parent.Parent.Parent.Parent.GetDirectories("Ryujinx")[0].GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName;
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
string data;
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
using (StreamReader sr = new StreamReader(path))
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
{
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
data = sr.ReadToEnd();
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
}
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
LocalesJSON json = JsonConvert.DeserializeObject<LocalesJSON>(data);
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
for (int i = 0; i < json.Locales.Count; i++)
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
{
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
LocalesEntry locale = json.Locales[i];
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
foreach (string language in json.Languages)
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
{
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
if (!locale.Translations.ContainsKey(language))
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
{
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
locale.Translations.Add(language, "");
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
Log.LogMessage(MessageImportance.High, $"Added {{{language}}} to Locale {{{locale.ID}}}");
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
}
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
}
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
locale.Translations = locale.Translations.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value);
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
json.Locales[i] = locale;
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
}
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
string jsonString = JsonConvert.SerializeObject(json, Formatting.Indented);
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
using (StreamWriter sw = new StreamWriter(path))
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
{
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
sw.Write(jsonString);
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
}
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
return true;
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
}
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
struct LocalesJSON
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
{
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
public List<string> Languages { get; set; }
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
public List<LocalesEntry> Locales { get; set; }
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
}
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
struct LocalesEntry
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
{
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
public string ID { get; set; }
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
public Dictionary<string, string> Translations { get; set; }
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
}
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
}
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`
}
WilliamWsyHK commented 2024-12-18 13:51:48 +00:00 (Migrated from github.com)
Review

A minor comment: LocalesJSON -> LocalesJson

A minor comment: `LocalesJSON` -> `LocalesJson`

View File

@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" />
<PackageReference Include="Newtonsoft.Json" />
</ItemGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -152,8 +152,6 @@ namespace Ryujinx.Ava.Common.Locale
var localeStrings = new Dictionary<LocaleKeys, string>();
string fileData = EmbeddedResources.ReadAllText($"Ryujinx/Assets/locales.json");
bool invalidLocalesJson = false; //does the locales.json contain all the languages in all the locales?
if (fileData == null)
{
// We were unable to find file for that language code.
@ -167,12 +165,7 @@ namespace Ryujinx.Ava.Common.Locale
if (locale.Translations.Count != json.Languages.Count)
{
Logger.Error?.Print(LogClass.UI, $"Locale key {{{locale.ID}}} is missing languages!");
invalidLocalesJson = true;
#if DEBUG
break;
#else
throw new Exception("Missing locale data!");
#endif
}
if (Enum.TryParse<LocaleKeys>(locale.ID, out var localeKey))
@ -189,45 +182,6 @@ namespace Ryujinx.Ava.Common.Locale
}
}
if (invalidLocalesJson)
{
for (int i = 0; i < json.Locales.Count; i++)
{
LocalesEntry locale = json.Locales[i];
foreach (string language in json.Languages)
{
if (!locale.Translations.ContainsKey(language))
{
locale.Translations.Add(language, "");
Logger.Warning?.Print(LogClass.UI, $"Added {{{language}}} to Locale {{{locale.ID}}}");
}
}
locale.Translations = locale.Translations.OrderBy(pair => pair.Key).ToDictionary(pair => pair.Key, pair => pair.Value);
json.Locales[i] = locale;
}
string location = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.GetDirectories("Assets")[0].GetFiles("locales.json")[0].FullName;
JsonSerializerOptions jsonOptions = new JsonSerializerOptions
{
WriteIndented = true,
Encoder = JavaScriptEncoder.Create(UnicodeRanges.All)
};
LocalesJSONContext context = new LocalesJSONContext(jsonOptions);
string jsonString = JsonHelper.Serialize(json, context.LocalesJSON);
using (StreamWriter sw = new StreamWriter(location))
{
sw.Write(jsonString);
}
throw new Exception("Missing locale data! (missing locale data has been added, please rebuild the project)");
}
return localeStrings;
}
}

View File

@ -13,6 +13,12 @@
<DefaultItemExcludes>$(DefaultItemExcludes);._*</DefaultItemExcludes>
</PropertyGroup>
<UsingTask TaskName="Ryujinx.BuildValidationTasks.LocaleValidationTask" AssemblyFile="$(ProjectDir)..\Ryujinx.BuildValidationTasks\bin\debug\netstandard2.0\Ryujinx.BuildValidationTasks.dll" />
<Target Name="LocalesJsonValidation" BeforeTargets="BeforeBuild">
<LocaleValidationTask />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="$([MSBuild]::IsOSPlatform('OSX'))">
<Exec Command="codesign --entitlements '$(ProjectDir)..\..\distribution\macos\entitlements.xml' -f -s $(SigningCertificate) '$(TargetDir)$(TargetName)'" />
</Target>
@ -60,6 +66,7 @@
<ItemGroup>
<ProjectReference Include="..\Ryujinx.Audio.Backends.SDL2\Ryujinx.Audio.Backends.SDL2.csproj" />
<ProjectReference Include="..\Ryujinx.BuildValidationTasks\Ryujinx.BuildValidationTasks.csproj" />
<ProjectReference Include="..\Ryujinx.Graphics.Vulkan\Ryujinx.Graphics.Vulkan.csproj" />
<ProjectReference Include="..\Ryujinx.Input\Ryujinx.Input.csproj" />
<ProjectReference Include="..\Ryujinx.Input.SDL2\Ryujinx.Input.SDL2.csproj" />