Fixed culture code handling
This commit is contained in:
parent
c9bd1b5be9
commit
a47b18b7a8
@ -233,7 +233,7 @@ public static class AppSettings
|
|||||||
await using var db = ProcessorMeta.ServiceProvider.GetRequiredService<DataContext>();
|
await using var db = ProcessorMeta.ServiceProvider.GetRequiredService<DataContext>();
|
||||||
|
|
||||||
// Count the number of cultures:
|
// Count the number of cultures:
|
||||||
var count = await db.Settings.CountAsync(n => n.Code == SettingNames.CULTURE);
|
var count = await db.Settings.CountAsync(n => n.Code.StartsWith(SettingNames.CULTURE));
|
||||||
|
|
||||||
// We have at least one default culture:
|
// We have at least one default culture:
|
||||||
if(count == 0)
|
if(count == 0)
|
||||||
@ -263,7 +263,7 @@ public static class AppSettings
|
|||||||
await using var db = ProcessorMeta.ServiceProvider.GetRequiredService<DataContext>();
|
await using var db = ProcessorMeta.ServiceProvider.GetRequiredService<DataContext>();
|
||||||
|
|
||||||
// Get the culture code:
|
// Get the culture code:
|
||||||
var code = await db.Settings.FirstOrDefaultAsync(n => n.Code == SettingNames.CULTURE && n.IntegerValue == index);
|
var code = await db.Settings.FirstOrDefaultAsync(n => n.Code.StartsWith(SettingNames.CULTURE) && n.IntegerValue == index);
|
||||||
|
|
||||||
// When the culture code is not set & index = 1, use the default culture en-US:
|
// When the culture code is not set & index = 1, use the default culture en-US:
|
||||||
if(code is null && index == 1)
|
if(code is null && index == 1)
|
||||||
@ -291,7 +291,7 @@ public static class AppSettings
|
|||||||
await using var db = ProcessorMeta.ServiceProvider.GetRequiredService<DataContext>();
|
await using var db = ProcessorMeta.ServiceProvider.GetRequiredService<DataContext>();
|
||||||
|
|
||||||
// Check, if the setting is already set:
|
// Check, if the setting is already set:
|
||||||
if (await db.Settings.FirstOrDefaultAsync(n => n.Code == SettingNames.CULTURE && n.IntegerValue == index) is {} existingSetting)
|
if (await db.Settings.FirstOrDefaultAsync(n => n.Code.StartsWith(SettingNames.CULTURE) && n.IntegerValue == index) is {} existingSetting)
|
||||||
{
|
{
|
||||||
existingSetting.TextValue = code;
|
existingSetting.TextValue = code;
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
@ -302,7 +302,7 @@ public static class AppSettings
|
|||||||
{
|
{
|
||||||
var setting = new Setting
|
var setting = new Setting
|
||||||
{
|
{
|
||||||
Code = SettingNames.CULTURE,
|
Code = $"{SettingNames.CULTURE} {index}",
|
||||||
IntegerValue = index,
|
IntegerValue = index,
|
||||||
TextValue = code,
|
TextValue = code,
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user