Added localisation support

This commit is contained in:
2019-05-20 21:11:16 +01:00
parent 546d0bf7f4
commit d328c3ae4d
4 changed files with 251 additions and 36 deletions
@@ -0,0 +1,36 @@
using System.Globalization;
using System.Threading;
using System.Resources;
using System.Reflection;
namespace ASCOM.Meade.net.Localization
{
internal class LocalisationHelper
{
private const string LocalizationNamespace = "LocalisationTest.Localization.Resources.Localization";
ResourceManager _resourceManager;
public LocalisationHelper()
{
_resourceManager = new ResourceManager(LocalizationNamespace, Assembly.GetExecutingAssembly());
SetLocalisation(CultureInfo.CurrentCulture.Name);
}
internal void SetLocalisation(string name)
{
var cultureInfo = new CultureInfo(name);
CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
Thread.CurrentThread.CurrentCulture = cultureInfo;
Thread.CurrentThread.CurrentUICulture = cultureInfo;
}
internal string GetString(string key)
{
return _resourceManager.GetString(key);
}
}
}
+2
View File
@@ -81,6 +81,7 @@
<DependentUpon>frmMain.cs</DependentUpon>
</Compile>
<Compile Include="GarbageCollection.cs" />
<Compile Include="Localization\LocalisationHelper.cs" />
<Compile Include="LocalServer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="frmMain.resx">
@@ -136,6 +137,7 @@
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
+9 -36
View File
@@ -28,6 +28,7 @@ namespace ASCOM.Meade.net
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SetupDialogForm));
this.cmdOK = new System.Windows.Forms.Button();
this.cmdCancel = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
@@ -40,81 +41,55 @@ namespace ASCOM.Meade.net
//
// cmdOK
//
this.cmdOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
resources.ApplyResources(this.cmdOK, "cmdOK");
this.cmdOK.DialogResult = System.Windows.Forms.DialogResult.OK;
this.cmdOK.Location = new System.Drawing.Point(281, 112);
this.cmdOK.Name = "cmdOK";
this.cmdOK.Size = new System.Drawing.Size(59, 24);
this.cmdOK.TabIndex = 0;
this.cmdOK.Text = "OK";
this.cmdOK.UseVisualStyleBackColor = true;
//
// cmdCancel
//
this.cmdCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
resources.ApplyResources(this.cmdCancel, "cmdCancel");
this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cmdCancel.Location = new System.Drawing.Point(281, 142);
this.cmdCancel.Name = "cmdCancel";
this.cmdCancel.Size = new System.Drawing.Size(59, 25);
this.cmdCancel.TabIndex = 1;
this.cmdCancel.Text = "Cancel";
this.cmdCancel.UseVisualStyleBackColor = true;
this.cmdCancel.Click += new System.EventHandler(this.cmdCancel_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(12, 9);
resources.ApplyResources(this.label1, "label1");
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(123, 31);
this.label1.TabIndex = 2;
this.label1.Text = "Construct your driver\'s setup dialog here.";
//
// picASCOM
//
this.picASCOM.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
resources.ApplyResources(this.picASCOM, "picASCOM");
this.picASCOM.Cursor = System.Windows.Forms.Cursors.Hand;
this.picASCOM.Image = global::ASCOM.Meade.net.Properties.Resources.ASCOM;
this.picASCOM.Location = new System.Drawing.Point(292, 9);
this.picASCOM.Name = "picASCOM";
this.picASCOM.Size = new System.Drawing.Size(48, 56);
this.picASCOM.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.picASCOM.TabIndex = 3;
this.picASCOM.TabStop = false;
this.picASCOM.Click += new System.EventHandler(this.BrowseToAscom);
this.picASCOM.DoubleClick += new System.EventHandler(this.BrowseToAscom);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(13, 90);
resources.ApplyResources(this.label2, "label2");
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(58, 13);
this.label2.TabIndex = 5;
this.label2.Text = "Comm Port";
//
// chkTrace
//
this.chkTrace.AutoSize = true;
this.chkTrace.Location = new System.Drawing.Point(77, 118);
resources.ApplyResources(this.chkTrace, "chkTrace");
this.chkTrace.Name = "chkTrace";
this.chkTrace.Size = new System.Drawing.Size(69, 17);
this.chkTrace.TabIndex = 6;
this.chkTrace.Text = "Trace on";
this.chkTrace.UseVisualStyleBackColor = true;
//
// comboBoxComPort
//
this.comboBoxComPort.FormattingEnabled = true;
this.comboBoxComPort.Location = new System.Drawing.Point(77, 87);
resources.ApplyResources(this.comboBoxComPort, "comboBoxComPort");
this.comboBoxComPort.Name = "comboBoxComPort";
this.comboBoxComPort.Size = new System.Drawing.Size(90, 21);
this.comboBoxComPort.TabIndex = 7;
//
// SetupDialogForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(350, 175);
this.Controls.Add(this.comboBoxComPort);
this.Controls.Add(this.chkTrace);
this.Controls.Add(this.label2);
@@ -127,8 +102,6 @@ namespace ASCOM.Meade.net
this.MinimizeBox = false;
this.Name = "SetupDialogForm";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Meade.net Setup";
((System.ComponentModel.ISupportInitialize)(this.picASCOM)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
+204
View File
@@ -117,4 +117,208 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="cmdOK.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="cmdOK.Location" type="System.Drawing.Point, System.Drawing">
<value>281, 112</value>
</data>
<data name="cmdOK.Size" type="System.Drawing.Size, System.Drawing">
<value>59, 24</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="cmdOK.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="cmdOK.Text" xml:space="preserve">
<value>OK</value>
</data>
<data name="&gt;&gt;cmdOK.Name" xml:space="preserve">
<value>cmdOK</value>
</data>
<data name="&gt;&gt;cmdOK.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cmdOK.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;cmdOK.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="cmdCancel.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Bottom, Right</value>
</data>
<data name="cmdCancel.Location" type="System.Drawing.Point, System.Drawing">
<value>281, 142</value>
</data>
<data name="cmdCancel.Size" type="System.Drawing.Size, System.Drawing">
<value>59, 25</value>
</data>
<data name="cmdCancel.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="cmdCancel.Text" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="&gt;&gt;cmdCancel.Name" xml:space="preserve">
<value>cmdCancel</value>
</data>
<data name="&gt;&gt;cmdCancel.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cmdCancel.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;cmdCancel.ZOrder" xml:space="preserve">
<value>5</value>
</data>
<data name="label1.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 9</value>
</data>
<data name="label1.Size" type="System.Drawing.Size, System.Drawing">
<value>123, 31</value>
</data>
<data name="label1.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="label1.Text" xml:space="preserve">
<value>Meade AutoStar and AudioStar generic driver</value>
</data>
<data name="&gt;&gt;label1.Name" xml:space="preserve">
<value>label1</value>
</data>
<data name="&gt;&gt;label1.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label1.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label1.ZOrder" xml:space="preserve">
<value>4</value>
</data>
<data name="picASCOM.Anchor" type="System.Windows.Forms.AnchorStyles, System.Windows.Forms">
<value>Top, Right</value>
</data>
<data name="picASCOM.Location" type="System.Drawing.Point, System.Drawing">
<value>292, 9</value>
</data>
<data name="picASCOM.Size" type="System.Drawing.Size, System.Drawing">
<value>48, 56</value>
</data>
<data name="picASCOM.SizeMode" type="System.Windows.Forms.PictureBoxSizeMode, System.Windows.Forms">
<value>AutoSize</value>
</data>
<data name="picASCOM.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="&gt;&gt;picASCOM.Name" xml:space="preserve">
<value>picASCOM</value>
</data>
<data name="&gt;&gt;picASCOM.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;picASCOM.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;picASCOM.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="label2.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="label2.Location" type="System.Drawing.Point, System.Drawing">
<value>13, 90</value>
</data>
<data name="label2.Size" type="System.Drawing.Size, System.Drawing">
<value>58, 13</value>
</data>
<data name="label2.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="label2.Text" xml:space="preserve">
<value>Comm Port</value>
</data>
<data name="&gt;&gt;label2.Name" xml:space="preserve">
<value>label2</value>
</data>
<data name="&gt;&gt;label2.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;label2.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;label2.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="chkTrace.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="chkTrace.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 118</value>
</data>
<data name="chkTrace.Size" type="System.Drawing.Size, System.Drawing">
<value>69, 17</value>
</data>
<data name="chkTrace.TabIndex" type="System.Int32, mscorlib">
<value>6</value>
</data>
<data name="chkTrace.Text" xml:space="preserve">
<value>Trace on</value>
</data>
<data name="&gt;&gt;chkTrace.Name" xml:space="preserve">
<value>chkTrace</value>
</data>
<data name="&gt;&gt;chkTrace.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;chkTrace.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;chkTrace.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="comboBoxComPort.Location" type="System.Drawing.Point, System.Drawing">
<value>77, 87</value>
</data>
<data name="comboBoxComPort.Size" type="System.Drawing.Size, System.Drawing">
<value>90, 21</value>
</data>
<data name="comboBoxComPort.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="&gt;&gt;comboBoxComPort.Name" xml:space="preserve">
<value>comboBoxComPort</value>
</data>
<data name="&gt;&gt;comboBoxComPort.Type" xml:space="preserve">
<value>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;comboBoxComPort.Parent" xml:space="preserve">
<value>$this</value>
</data>
<data name="&gt;&gt;comboBoxComPort.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
<value>6, 13</value>
</data>
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
<value>350, 175</value>
</data>
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
<value>CenterScreen</value>
</data>
<data name="$this.Text" xml:space="preserve">
<value>Meade.net Setup</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>SetupDialogForm</value>
</data>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>