mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
d47bb1d297
With the new version of Visual Studio bringing C# 12, we can revise our logic for better readability as well as use new methods/APIs introduced in the .NET 8.0 BCL.
18 lines
1 KiB
C#
18 lines
1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Parameter | AttributeTargets.Delegate | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter)]
|
|
public sealed class LocalizedDescriptionAttribute(string fallback, [CallerMemberName] string? key = null)
|
|
: DescriptionAttribute
|
|
{
|
|
public static IReadOnlyDictionary<string, string> Localizer { private get; set; } = new Dictionary<string, string>();
|
|
|
|
public readonly string Fallback = fallback;
|
|
public readonly string Key = $"LocalizedDescription.{key!}";
|
|
|
|
public override string Description => Localizer.GetValueOrDefault(Key, Fallback);
|
|
}
|