Ruslan
Ruslan

Reputation: 171

How to set default Language in ABP framework?

I'm using Abp startup template with Blazor UI and EF Core I'm building a single language web app and basically want to get rid of every other language and set Turkish ("tr") for the default language/culture.

What is the recommended way to achieve this, without having to install any third-party NuGet package (such as Owl)?

Please note that I'm still new to the Abp Framework, so kindly include the file/project names in your answer(along with the code snippet, if possible)

Upvotes: 1

Views: 2385

Answers (1)

berkansasmaz
berkansasmaz

Reputation: 646

To remove all other languages and use Turkish ("tr") by default, you can update the ConfigureLocalization method in the ProjectNameHttpApiHostModule file under the ProjectName.HttpApi.Host folder to include the only tr. For example, the content of the ConfigureLocalization method should now be as follows:

    private void ConfigureLocalization()
    {
        Configure<AbpLocalizationOptions>(options =>
        {
            options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
        });
    }

Then you should add the following to the OnApplicationInitialization method in the ProjectNameHttpApiHostModule file.

    var supportedCultures = new[]
    {
        new CultureInfo("tr")
    };
    app.UseAbpRequestLocalization(options =>
    {
        options.DefaultRequestCulture = new RequestCulture("tr");
        options.SupportedCultures = supportedCultures;
        options.SupportedUICultures = supportedCultures;
        options.RequestCultureProviders = new List<IRequestCultureProvider>
        {
            new QueryStringRequestCultureProvider(),
            new CookieRequestCultureProvider()
        };
    });

See this issue for more information.

Upvotes: 4

Related Questions