using Newtonsoft.Json.Linq;

namespace Knoks.Framework.Content
{
    public class ContentModel
    {
        public ContentSettings ContentSettings { get; }
        public JObject DefaulContent { get; }
        public JObject LocalizedContent { get; }

        public ContentModel(ContentSettings contentSettings, JObject defaultContent, JObject localizedContent)
        {
            ContentSettings = contentSettings;
            DefaulContent = defaultContent;
            LocalizedContent = localizedContent;
        }

        public string this[string key]
        {
            get
            {
                key = $"[{key}]";
                return (LocalizedContent[key] ?? DefaulContent[key] ?? key).ToString();
            }
        }
    }
}
