using PlantBox.Client.Resources;
using System;
using System.Collections.Generic;
using System.Resources;
using System.Text;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace PlantBox.Client.Extensions
{
    [ContentProperty(nameof(Name))]
    public class LocaleExtension : IMarkupExtension
    {
        public string Name { get; set; }

        private static ResourceManager _resourceManager;

        static LocaleExtension()
        {
            _resourceManager = Locale.ResourceManager;
        }

        public object ProvideValue(IServiceProvider serviceProvider)
        {
            return _resourceManager.GetString(Name, Locale.Culture) ?? $"#{Name}";
        }
    }
}
