Base solution for your next web application
Open Closed

Abp.Localization.DefaultLanguageName #5793


User avatar
0
greatsamps created

Hi,

I am having some real issues with this combined with MultiTenancy. I have two languages enabled at host level, english and spanish, with english being the default. I have created a TenantLevel setting for the above name pointing it to spanish (es). This works well, you can browse to the tenant and its all in spanish.

The problem occurs when creating or logging in as a user. Looking at the database settings table, each time a page is loaded for a logged in user, an entry is created in the table for the above setting, with a value of "null". Due to this setting existing, but with a value of "null", it can't resolve the language and it reverts to the host default of english.

For the sake of clarity, when i say its set to "null" i mean a string comprising of 4 letters "null" not an actual NULL value.

I have tried looking at the source code, and i can't see where it is setting this value or why. I am currently working through the code trying to figure this out, but there is clearly something not right here.

Any ideas?

Kind Regards,

Done some more digging on this, and it appears that problem is related to this method:

public override Task DetermineProviderCultureResult(HttpContext httpContext)
{
if (httpContext == null)
{
throw new ArgumentNullException(nameof(httpContext));
}

    var localizationHeader = httpContext.Request.Headers[CookieRequestCultureProvider.DefaultCookieName];

    if (localizationHeader.Count == 0)
    {
        return Task.FromResult((ProviderCultureResult) null);
    }

    return Task.FromResult(ParseHeaderValue(localizationHeader));
}

var localizationHeader = httpContext.Request.Headers[CookieRequestCultureProvider.DefaultCookieName];

This cookie does not exist on the client, but it is still returning a result, with null as the culture id.


4 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Your problem might be related to this https://github.com/aspnetzero/aspnet-zero-core/issues/1254#issuecomment-404817559

  • User Avatar
    0
    greatsamps created

    I have taken an look at that, and whilst the symptoms are exactly the same, i do unfortunatally have that record in my settings database.

    One other thing that i noticed that is a little odd. Under the host, i have all languages apart from english (en-GB) and spanish disabled, with english set to the default. When i log in under the tenant admin, i see all of the languages (including disabled ones) showing 'YES' under the default column, english is in bold with (default) written after it however.

  • User Avatar
    0
    ismcagdas created
    Support Team

    @greatsamps

    If it is possible, please send your project to [email protected] and let us check it for you.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Closing because the issue is handled via email support now.