Fixed translations when rename cultures

This commit is contained in:
Thorsten Sommer 2022-11-01 20:40:19 +01:00
parent 6e8eb493e0
commit 9023a6d7b7
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -268,6 +268,9 @@ public static class AppSettings
public static async Task SetCultureCode(int index, string code)
{
// Keep a copy of the previous name:
var previousCode = await AppSettings.GetCultureCode(index);
// Update the cache:
CACHE_CULTURES[index] = code;
@ -297,6 +300,13 @@ public static class AppSettings
// Update the list of cultures indices:
CACHE_CULTURES_INDICES.Add(index);
}
// Next, we need to rename the culture inside all translations as well:
var translations = await db.Translations.Where(n => n.Culture == previousCode).ToListAsync();
foreach (var translation in translations)
translation.Culture = code;
await db.SaveChangesAsync();
}
#endregion