mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-10 17:46:27 +02:00
Unified locales (#391)
Use 1 locales file instead of individual files for each langauge. This makes it easier to keep track of what is missing. The PR will automatically fix missing locales and throw an error if anything is incorrect, by running the emulator. That way the person adding a new locale or new language can just run the emulator once to populate all the fields, so they can easily begin translating.
This commit is contained in:
parent
0adaa4cb96
commit
9cddf3b66b
28 changed files with 21728 additions and 16810 deletions
|
@ -3,9 +3,7 @@ using Avalonia.Controls;
|
|||
using Avalonia.Interactivity;
|
||||
using Avalonia.Threading;
|
||||
using Gommon;
|
||||
using LibHac.Common;
|
||||
using LibHac.Ncm;
|
||||
using LibHac.Ns;
|
||||
using LibHac.Tools.FsSystem.NcaUtils;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
using Ryujinx.Ava.UI.Helpers;
|
||||
|
@ -21,9 +19,7 @@ using Ryujinx.UI.Common.Configuration;
|
|||
using Ryujinx.UI.Common.Helper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Ryujinx.Ava.UI.Views.Main
|
||||
{
|
||||
|
@ -58,29 +54,31 @@ namespace Ryujinx.Ava.UI.Views.Main
|
|||
{
|
||||
List<MenuItem> menuItems = new();
|
||||
|
||||
string localePath = "Ryujinx/Assets/Locales";
|
||||
string localeExt = ".json";
|
||||
string localePath = "Ryujinx/Assets/locales.json";
|
||||
|
||||
string[] localesPath = EmbeddedResources.GetAllAvailableResources(localePath, localeExt);
|
||||
string languageJson = EmbeddedResources.ReadAllText(localePath);
|
||||
|
||||
Array.Sort(localesPath);
|
||||
LocalesJson locales = JsonHelper.Deserialize(languageJson, LocalesJsonContext.Default.LocalesJson);
|
||||
|
||||
foreach (string locale in localesPath)
|
||||
foreach (string language in locales.Languages)
|
||||
{
|
||||
string languageCode = Path.GetFileNameWithoutExtension(locale).Split('.').Last();
|
||||
string languageJson = EmbeddedResources.ReadAllText($"{localePath}/{languageCode}{localeExt}");
|
||||
var strings = JsonHelper.Deserialize(languageJson, CommonJsonContext.Default.StringDictionary);
|
||||
int index = locales.Locales.FindIndex(x => x.ID == "Language");
|
||||
string languageName;
|
||||
|
||||
if (!strings.TryGetValue("Language", out string languageName))
|
||||
if (index == -1)
|
||||
{
|
||||
languageName = languageCode;
|
||||
languageName = language;
|
||||
}
|
||||
else
|
||||
{
|
||||
languageName = locales.Locales[index].Translations[language] == "" ? language : locales.Locales[index].Translations[language];
|
||||
}
|
||||
|
||||
MenuItem menuItem = new()
|
||||
{
|
||||
Padding = new Thickness(10, 0, 0, 0),
|
||||
Header = " " + languageName,
|
||||
Command = MiniCommand.Create(() => MainWindowViewModel.ChangeLanguage(languageCode))
|
||||
Command = MiniCommand.Create(() => MainWindowViewModel.ChangeLanguage(language))
|
||||
};
|
||||
|
||||
menuItems.Add(menuItem);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue