Starts in:
1 DAY
23 HRS
20 MIN
50 SEC
Starts in:
1 D
23 H
20 M
50 S
Open Closed

How to set default language as Chinese in Blazor Server App? #2504


User avatar
0
zhongfang created

My clients want to look Chinese UI, while they touch my web application.

How to do ?

  • ABP Framework version: v5.1.1
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no

2 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @zhongfang, you can update your UseAbpRequestLocalization middleware (under your *.HttpApiHostModule) as follows:

    //list your supported cultures
    var supportedCultures = new[]
    {
        new CultureInfo("zh-Hans"),
        new CultureInfo("cs"),
        new CultureInfo("en"),
        new CultureInfo("tr"),
        //...
    };
    
    app.UseAbpRequestLocalization(options =>
    {
        options.DefaultRequestCulture = new RequestCulture("zh-Hans"); //set default as zh-Hans
        options.SupportedCultures = supportedCultures;
        options.SupportedUICultures = supportedCultures;
        options.RequestCultureProviders = new List<IRequestCultureProvider>
        {
            // there are three culture providers
            new QueryStringRequestCultureProvider(),
            new CookieRequestCultureProvider(),
            new AcceptLanguageHeaderRequestCultureProvider()
        };
    });
    

    https://github.com/abpframework/abp/issues/2775 https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-6.0#localization-middleware

  • User Avatar
    0
    zhongfang created

    I found many result articles by search Google and Baidu. And I tried out them. But I failed.

    Now, you resolved my question.

    Thank you.

    Maybe you can add above content to UserGuide.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06