From 9023a6d7b75efc235445ceed94f4ef621fc08b70 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Tue, 1 Nov 2022 20:40:19 +0100 Subject: [PATCH] Fixed translations when rename cultures --- I18N Commander/Processor/AppSettings.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/I18N Commander/Processor/AppSettings.cs b/I18N Commander/Processor/AppSettings.cs index fc3e43f..5c177ae 100644 --- a/I18N Commander/Processor/AppSettings.cs +++ b/I18N Commander/Processor/AppSettings.cs @@ -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