Avalonia - Add source generator for locale items (#3999)
* Add source generator for locale keys * use locale keys in Ui subdir
This commit is contained in:
parent
09c9686498
commit
02714a1291
40 changed files with 337 additions and 271 deletions
|
@ -2,6 +2,7 @@
|
|||
using Ryujinx.Common;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.Ui.Common.Configuration;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
@ -13,17 +14,17 @@ namespace Ryujinx.Ava.Common.Locale
|
|||
{
|
||||
private const string DefaultLanguageCode = "en_US";
|
||||
|
||||
private Dictionary<string, string> _localeStrings;
|
||||
private ConcurrentDictionary<string, object[]> _dynamicValues;
|
||||
private Dictionary<LocaleKeys, string> _localeStrings;
|
||||
private ConcurrentDictionary<LocaleKeys, object[]> _dynamicValues;
|
||||
|
||||
public static LocaleManager Instance { get; } = new LocaleManager();
|
||||
public Dictionary<string, string> LocaleStrings { get => _localeStrings; set => _localeStrings = value; }
|
||||
public Dictionary<LocaleKeys, string> LocaleStrings { get => _localeStrings; set => _localeStrings = value; }
|
||||
|
||||
|
||||
public LocaleManager()
|
||||
{
|
||||
_localeStrings = new Dictionary<string, string>();
|
||||
_dynamicValues = new ConcurrentDictionary<string, object[]>();
|
||||
_localeStrings = new Dictionary<LocaleKeys, string>();
|
||||
_dynamicValues = new ConcurrentDictionary<LocaleKeys, object[]>();
|
||||
|
||||
Load();
|
||||
}
|
||||
|
@ -49,7 +50,7 @@ namespace Ryujinx.Ava.Common.Locale
|
|||
}
|
||||
}
|
||||
|
||||
public string this[string key]
|
||||
public string this[LocaleKeys key]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -63,7 +64,7 @@ namespace Ryujinx.Ava.Common.Locale
|
|||
return value;
|
||||
}
|
||||
|
||||
return key;
|
||||
return key.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
|
@ -73,7 +74,7 @@ namespace Ryujinx.Ava.Common.Locale
|
|||
}
|
||||
}
|
||||
|
||||
public void UpdateDynamicValue(string key, params object[] values)
|
||||
public void UpdateDynamicValue(LocaleKeys key, params object[] values)
|
||||
{
|
||||
_dynamicValues[key] = values;
|
||||
|
||||
|
@ -98,7 +99,10 @@ namespace Ryujinx.Ava.Common.Locale
|
|||
|
||||
foreach (var item in strings)
|
||||
{
|
||||
this[item.Key] = item.Value;
|
||||
if (Enum.TryParse<LocaleKeys>(item.Key, out var key))
|
||||
{
|
||||
this[key] = item.Value;
|
||||
}
|
||||
}
|
||||
|
||||
if (Program.PreviewerDetached)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue