2022-01-26 11:32:16 -05:00
|
|
|
|
using System.Collections.Generic;
|
2020-08-17 22:21:11 -04:00
|
|
|
|
using System.Globalization;
|
2022-01-26 11:32:16 -05:00
|
|
|
|
using SharedLibraryCore.Interfaces;
|
2018-04-22 16:04:18 -04:00
|
|
|
|
|
|
|
|
|
namespace SharedLibraryCore.Localization
|
|
|
|
|
{
|
|
|
|
|
public class Layout
|
|
|
|
|
{
|
2020-08-17 22:21:11 -04:00
|
|
|
|
private string localizationName;
|
2022-01-26 11:32:16 -05:00
|
|
|
|
|
|
|
|
|
public Layout(Dictionary<string, string> set)
|
|
|
|
|
{
|
|
|
|
|
LocalizationIndex = new TranslationLookup
|
|
|
|
|
{
|
|
|
|
|
Set = set
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-17 22:21:11 -04:00
|
|
|
|
public string LocalizationName
|
|
|
|
|
{
|
|
|
|
|
get => localizationName;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
localizationName = value;
|
|
|
|
|
Culture = new CultureInfo(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-26 11:32:16 -05:00
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public TranslationLookup LocalizationIndex { get; set; }
|
2020-08-17 22:21:11 -04:00
|
|
|
|
public CultureInfo Culture { get; private set; }
|
2018-05-05 16:36:26 -04:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-26 19:06:50 -05:00
|
|
|
|
public class TranslationLookup : ITranslationLookup
|
2018-05-05 16:36:26 -04:00
|
|
|
|
{
|
|
|
|
|
public Dictionary<string, string> Set { get; set; }
|
|
|
|
|
|
|
|
|
|
public string this[string key]
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2022-01-26 11:32:16 -05:00
|
|
|
|
if (!Set.TryGetValue(key, out var value))
|
2018-08-28 17:32:59 -04:00
|
|
|
|
{
|
2018-09-13 21:00:41 -04:00
|
|
|
|
return key;
|
2018-08-28 17:32:59 -04:00
|
|
|
|
}
|
2022-01-26 11:32:16 -05:00
|
|
|
|
|
2018-05-05 16:36:26 -04:00
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-22 16:04:18 -04:00
|
|
|
|
}
|
2022-01-26 11:32:16 -05:00
|
|
|
|
}
|