mirror of
https://github.com/abdelkader/vCardEditor
synced 2025-12-12 08:27:19 +07:00
31 lines
834 B
C#
31 lines
834 B
C#
using vCardEditor.Repository;
|
|
|
|
namespace vCardEditor.Libs.TinyJson
|
|
{
|
|
public class LocalizationLoader
|
|
{
|
|
private readonly IParser _parser;
|
|
private readonly IFileHandler _fileHandler;
|
|
|
|
public LocalizationLoader(IParser parser, IFileHandler fileHandler)
|
|
{
|
|
_parser = parser;
|
|
_fileHandler = fileHandler;
|
|
}
|
|
|
|
public LocalizationFile LoadEmbedded(string EmbeddedResourceName = "vCardEditor.i18n.lang.json")
|
|
{
|
|
string json = _fileHandler.LoadJsonFromAssembly(EmbeddedResourceName);
|
|
return Deserialize(json);
|
|
}
|
|
|
|
|
|
private LocalizationFile Deserialize(string json)
|
|
{
|
|
var result = _parser.Deserialize<LocalizationFile>(json);
|
|
return result ?? new LocalizationFile();
|
|
}
|
|
|
|
}
|
|
}
|