Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

614 B
Raw Blame
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;

namespace Grand.Web.Common.Routing;

public class LanguageParameterTransformer : IOutboundParameterTransformer
{
    private readonly IHttpContextAccessor _httpContextAccessor;

    public LanguageParameterTransformer(IHttpContextAccessor httpContextAccessor)
    {
        _httpContextAccessor = httpContextAccessor;
    }

    public string TransformOutbound(object value)
    {
        var lang = _httpContextAccessor.HttpContext?.Request.RouteValues["language"];
        return lang != null ? lang.ToString() : value?.ToString();
    }
}