- ABP Framework version: v4.3.3
- UI type: Angular
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no (Angular)
- Exception message and stack trace: N/A
- Steps to reproduce the issue:"
How do I set the default culture and UI culture of my Angular app?
I've configured my FooApiHostModule like so
private void ConfigureLocalization()
{
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Clear();
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English"));
});
}
I've duplicated the en.json localization file and renamed it en-GB, I've changed the Culture
elemein in the top of that file like so
{
"Culture": "en-GB",
"Texts": {
...
}
}
If I put a breakpoint in a controller action, and inspect System.Threading.Thread.CurrentThread.CurrentCulture
and System.Threading.Thread.CurrentThread.CurrentUICulture
they're both "en", not "en-GB".
How do I get my application to run in en-GB
?
I've also cahnged my Startup.Configure()
method like so, but this doesn't fix it either.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-GB"),
SupportedCultures =
{
new CultureInfo("en-GB")
},
SupportedUICultures =
{
new CultureInfo("en-GB")
}
});
}
3 Answer(s)
-
1
hi
Can you log in
admin
and check the language management page? -
0
To do it with code;
To remove all other languages and use English ("en-GB") by default, you can update the
ConfigureServices
method in theProjectNameDomainModule
file under theProjectName.Domain
folder to include the only "en-GB". For example, the content of theConfigureServices
method should now be as follows:public override void ConfigureServices(ServiceConfigurationContext context) { ... Configure<AbpLocalizationOptions>(options => { options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English")); }); ... }
Then you should add the following to the
OnApplicationInitialization
method in theProjectNameHttpApiHostModule
file.var supportedCultures = new[] { new CultureInfo("en-GB") }; app.UseAbpRequestLocalization(options => { options.DefaultRequestCulture = new RequestCulture("en-GB"); options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; options.RequestCultureProviders = new List<IRequestCultureProvider> { new QueryStringRequestCultureProvider(), new CookieRequestCultureProvider() }; });
Then just delete the data in the
AbpLanguages
table from the database and runProjectName.DbMigrator
. -
0
This question has been automatically marked as stale because it has not had recent activity.