PKHeX/PKHeX.Core/Util/Localization/LocalizedDescriptionAttribute.cs
Kurt 0d45075d4b
Rewrite settings handling; enhance some user experiences (#3193)
- Settings now stored as json next to exe
- Settings now exposes all legality checking setttings that can be changed
- Slot hovering now can play cries in MGDB/PKMDB/etc, not just the main boxes.
- Enhanced hover text for mystery gifts and encounters that have movesets
- Show recently loaded save files in ctrl-f browser
- Toggle auto-load savefile setting to be none/detect-latest/last-loaded
- Custom extensions & extra backup paths can now be configured directly in the json settings
- Settings editor now uses propertygrid & tabs.
2021-04-11 18:09:54 -07:00

24 lines
1.2 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;
}
}