2020-01-26 19:06:50 -05:00
|
|
|
|
using SharedLibraryCore.Interfaces;
|
2018-04-22 16:04:18 -04:00
|
|
|
|
using System.Collections.Generic;
|
2020-08-17 22:21:11 -04:00
|
|
|
|
using System.Globalization;
|
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;
|
|
|
|
|
public string LocalizationName
|
|
|
|
|
{
|
|
|
|
|
get => localizationName;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
localizationName = value;
|
|
|
|
|
Culture = new CultureInfo(value);
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
|
|
|
|
|
public Layout(Dictionary<string, string> set)
|
|
|
|
|
{
|
2020-01-26 19:06:50 -05:00
|
|
|
|
LocalizationIndex = new TranslationLookup()
|
2018-05-05 16:36:26 -04:00
|
|
|
|
{
|
|
|
|
|
Set = set
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
if (!Set.TryGetValue(key, out string 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
|
|
|
|
}
|
2018-05-05 16:36:26 -04:00
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-22 16:04:18 -04:00
|
|
|
|
}
|
2018-05-05 16:36:26 -04:00
|
|
|
|
|
2018-04-22 16:04:18 -04:00
|
|
|
|
}
|