using Processor; namespace UI_WinForms.Components; public partial class Translations : UserControl { private readonly Dictionary translationComponents = new(); public Translations() { this.InitializeComponent(); this.Load += async (sender, args) => await this.SetupTranslations(); AppEvents.WhenTextElementChanged += async (sender, textElement) => { var allTranslations = await TranslationProcessor.GetTranslations(textElement); foreach (var translation in allTranslations) if (this.translationComponents.ContainsKey(translation.Culture)) this.translationComponents[translation.Culture].Configure(translation); }; } private async Task SetupTranslations() { if(this.DesignMode) return; var cultureInfos = await AppSettings.GetCultureInfos(); foreach (var cultureInfo in cultureInfos) { var translationComponent = new Translation(cultureInfo.Code); this.translationComponents.Add(cultureInfo.Code, translationComponent); this.panelTranslations.Controls.Add(translationComponent); } } }