The code you provided seems to be setting the scLanguage route parameter based on a hardcoded value ("ab-AB" or "de-DE") depending on the Sitecore.Context.Language.Name property. This might be the reason why it's always returning "en".
To get the proper context language inside the processor, you should use the Sitecore.Context.Language property directly instead of hardcoding values. Here's the modified code:
{
public void Process(PipelineArgs args)
{
try
{
string siteName = "Default SiteName;
if(Sitecore.Context.Language.Name.Equals("ab-AB"))
{
siteName = "ABC";
}
else if(Sitecore.Context.Language.Name.Equals("de-DE"))
{
siteName = "DEF";
}
RouteTable.Routes.MapRoute(
name: "BlogPostPageRedirect",
url: "blogPost/page/{pageIndex}",
defaults: new
{
scItemPath = "/sitecore/content/" + siteName + "/Home/Blog",
controller = "Blog",
action = "GetBlogPost",
scLanguage = Sitecore.Context.Language
});
}
catch (Exception ex)
{
// Log or handle exception
}
}
}
This code retrieves the current language context from Sitecore.Context.Language and assigns it to the scLanguage route parameter. This should ensure that the route uses the actual language retrieved from the context.
You can add the custom processor you created to the mvc.renderRendering pipeline after the standard Sitecore MVC rendering resolvers.
Please try this once