Added a component which contains all translations
This commit is contained in:
parent
5ced6c3107
commit
c55d6dabc1
59
I18N Commander/UI WinForms/Components/Translations.Designer.cs
generated
Normal file
59
I18N Commander/UI WinForms/Components/Translations.Designer.cs
generated
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
namespace UI_WinForms.Components
|
||||||
|
{
|
||||||
|
partial class Translations
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Component Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
35
I18N Commander/UI WinForms/Components/Translations.cs
Normal file
35
I18N Commander/UI WinForms/Components/Translations.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using Processor;
|
||||||
|
|
||||||
|
namespace UI_WinForms.Components;
|
||||||
|
|
||||||
|
public partial class Translations : UserControl
|
||||||
|
{
|
||||||
|
private readonly Dictionary<string, Translation> 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
I18N Commander/UI WinForms/Components/Translations.resx
Normal file
60
I18N Commander/UI WinForms/Components/Translations.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
Loading…
Reference in New Issue
Block a user