Base solution for your next web application
Open Closed

Localization - Need to change only language #11752


User avatar
0
kansoftware created

Hi,

I want use localization for only language in both side client and server side, do not want to change date format and numeric / decimal format.

Could you please help for this.

Thanks Regards Mohit


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

    Hi @kansoftware

    In that case, you can create a custom culture provider and specify date format and numeric format in this custom class.

    You can create it like this;

    public class MyRequestCultureProvider : RequestCultureProvider
    {
    	public override Task DetermineProviderCultureResult(HttpContext httpContext)
    	{
    		var result = new ProviderCultureResult(culture: (StringSegment)"en-US", uiCulture: (StringSegment)"ar");
    		return Task.FromResult(result);
    	}
    }
    

    and use it like this;

    app.UseAbpRequestLocalization(opts =>
    {
    	opts.RequestCultureProviders.Insert(0, new MyRequestCultureProvider());
    });
    
  • User Avatar
    0
    kansoftware created

    I tried this code but now i am not able to change language. I just want to change language but do not want to change date format and numeric / decimal format.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    This was just a sample code. For a real example, you can take a look at https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.AspNetCore/AspNetCore/Localization/AbpUserRequestCultureProvider.cs and uiCulture or culture as you wish.