diff --git a/I18N Commander/UI WinForms/Components/Translations.Designer.cs b/I18N Commander/UI WinForms/Components/Translations.Designer.cs new file mode 100644 index 0000000..dd6f1c1 --- /dev/null +++ b/I18N Commander/UI WinForms/Components/Translations.Designer.cs @@ -0,0 +1,59 @@ +namespace UI_WinForms.Components +{ + partial class Translations + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panelTranslations = new System.Windows.Forms.Panel(); + this.SuspendLayout(); + // + // panelTranslations + // + this.panelTranslations.AutoScroll = true; + this.panelTranslations.Dock = System.Windows.Forms.DockStyle.Fill; + this.panelTranslations.Location = new System.Drawing.Point(0, 0); + this.panelTranslations.Name = "panelTranslations"; + this.panelTranslations.Size = new System.Drawing.Size(942, 462); + this.panelTranslations.TabIndex = 0; + // + // Translations + // + this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.Controls.Add(this.panelTranslations); + this.Font = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.Name = "Translations"; + this.Size = new System.Drawing.Size(942, 462); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panelTranslations; + } +} diff --git a/I18N Commander/UI WinForms/Components/Translations.cs b/I18N Commander/UI WinForms/Components/Translations.cs new file mode 100644 index 0000000..7cac38c --- /dev/null +++ b/I18N Commander/UI WinForms/Components/Translations.cs @@ -0,0 +1,35 @@ +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); + } + } +} \ No newline at end of file diff --git a/I18N Commander/UI WinForms/Components/Translations.resx b/I18N Commander/UI WinForms/Components/Translations.resx new file mode 100644 index 0000000..b5ae26c --- /dev/null +++ b/I18N Commander/UI WinForms/Components/Translations.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file