Added DefaultLanguage Customization
This commit is contained in:
parent
a3033e8646
commit
d6a70d0a03
|
@ -5,6 +5,7 @@ public class Customization {
|
||||||
public string AppDescription { get; set; } = "";
|
public string AppDescription { get; set; } = "";
|
||||||
public string AppUrl { get; set; } = "http://localhost";
|
public string AppUrl { get; set; } = "http://localhost";
|
||||||
public string DefaultTheme { get; set; } = "";
|
public string DefaultTheme { get; set; } = "";
|
||||||
|
public string DefaultLanguage { get; set; } = "";
|
||||||
public string LogoLink { get; set; } = "";
|
public string LogoLink { get; set; } = "";
|
||||||
public string Footer { get; set; } = "";
|
public string Footer { get; set; } = "";
|
||||||
}
|
}
|
|
@ -173,13 +173,15 @@
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
var customization = builder.Configuration.GetSection(nameof(Customization)).Get<Customization>();
|
||||||
string[] cultures = ["en-US", "en-GB", "de-DE"];
|
string[] cultures = ["en-US", "en-GB", "de-DE"];
|
||||||
|
|
||||||
|
string defaultLanguage = string.IsNullOrWhiteSpace(customization?.DefaultLanguage) ? cultures[0] : customization.DefaultLanguage;
|
||||||
builder.Services.Configure<RequestLocalizationOptions>(options => {
|
builder.Services.Configure<RequestLocalizationOptions>(options => {
|
||||||
options.ApplyCurrentCultureToResponseHeaders = true;
|
options.ApplyCurrentCultureToResponseHeaders = true;
|
||||||
options.FallBackToParentCultures = true;
|
options.FallBackToParentCultures = true;
|
||||||
options.FallBackToParentUICultures = true;
|
options.FallBackToParentUICultures = true;
|
||||||
options.SetDefaultCulture(cultures[0])
|
options.SetDefaultCulture(defaultLanguage)
|
||||||
.AddSupportedCultures(cultures)
|
.AddSupportedCultures(cultures)
|
||||||
.AddSupportedUICultures(cultures);
|
.AddSupportedUICultures(cultures);
|
||||||
});
|
});
|
||||||
|
@ -221,15 +223,15 @@
|
||||||
|
|
||||||
{
|
{
|
||||||
using var scope = app.Services.CreateScope();
|
using var scope = app.Services.CreateScope();
|
||||||
using var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
await using var context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||||
context.Database.Migrate();
|
context.Database.Migrate();
|
||||||
|
|
||||||
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
|
var userManager = scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
|
||||||
if (userManager.GetUsersInRoleAsync("Admin").Result.Any() is false) {
|
if (userManager.GetUsersInRoleAsync("Admin").Result.Any() is false) {
|
||||||
IDistributedCache cache = app.Services.GetRequiredService<IDistributedCache>();
|
var cache = app.Services.GetRequiredService<IDistributedCache>();
|
||||||
|
|
||||||
// Check first wheter the password exists already
|
// Check first wheter the password exists already
|
||||||
string admin = await cache.GetStringAsync("admin_promote_key");
|
string? admin = await cache.GetStringAsync("admin_promote_key");
|
||||||
|
|
||||||
// If it does not exist, create a new one and save it to redis
|
// If it does not exist, create a new one and save it to redis
|
||||||
if (string.IsNullOrWhiteSpace(admin)){
|
if (string.IsNullOrWhiteSpace(admin)){
|
||||||
|
|
Loading…
Reference in a new issue