PKHeX/PKHeX.Core/Util/Localization/LocalizedDescriptionAttribute.cs
Kurt fc754b346b
File scoped namespaces (#3529)
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces)

Updates all the files, one less level of indentation.

Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
2022-06-18 11:04:24 -07:00

23 lines
1.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 : DescriptionAttribute
{
public static IReadOnlyDictionary<string, string> Localizer { private get; set; } = new Dictionary<string, string>();
public readonly string Fallback;
public readonly string Key;
public LocalizedDescriptionAttribute(string fallback, [CallerMemberName] string? key = null)
{
Key = $"LocalizedDescription.{key!}";
Fallback = fallback;
}
public override string Description => Localizer.TryGetValue(Key, out var result) ? result : Fallback;
}