using Microsoft.Extensions.Localization;
using System;

namespace AMESCoreStudio.Web.Resources.Localization
{
    public class CustomStringLocalizerFactory : IStringLocalizerFactory
    {
        private readonly IStringLocalizerFactory _baseFactory;

        public CustomStringLocalizerFactory(IStringLocalizerFactory baseFactory)
        {
            _baseFactory = baseFactory;
        }

        public IStringLocalizer Create(Type resourceSource)
        {
            return _baseFactory.Create(resourceSource);
        }

        public IStringLocalizer Create(string baseName, string location)
        {
            // 自訂邏輯:如果是 Views.PCS,或是 Controllers.PCS,使用 Shared 資源
            if (baseName.Contains("Views.PCS") || baseName.Contains("Controllers.PCS"))
            {
                baseName = "Views.PCS.Shared";
            }
            return _baseFactory.Create(baseName, location);
        }
    }
}