IW4M-Admin/SharedLibraryCore/Localization/Layout.cs
2022-01-26 15:26:25 -06:00

50 lines
1.1 KiB
C#

using System.Collections.Generic;
using System.Globalization;
using SharedLibraryCore.Interfaces;
namespace SharedLibraryCore.Localization
{
public class Layout
{
private string localizationName;
public Layout(Dictionary<string, string> set)
{
LocalizationIndex = new TranslationLookup
{
Set = set
};
}
public string LocalizationName
{
get => localizationName;
set
{
localizationName = value;
Culture = new CultureInfo(value);
}
}
public TranslationLookup LocalizationIndex { get; set; }
public CultureInfo Culture { get; private set; }
}
public class TranslationLookup : ITranslationLookup
{
public Dictionary<string, string> Set { get; set; }
public string this[string key]
{
get
{
if (!Set.TryGetValue(key, out var value))
{
return key;
}
return value;
}
}
}
}