Vilket är enligt eran mening det bästa sättet att lokalisera ett program.Lokalisera program?
Om jag använder den inbyggda supporten för språkstöd så sätter man properties för fönstet. Jag har lagt till en enkel label innan.
Language - Sweden
Localizable - True
Innan lokaliseringen lades in såg den automatgenererade koden ut såhär:
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(80, 56);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
Efter lokaliseringen såg det ut såhär:
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AccessibleDescription = resources.GetString("label1.AccessibleDescription");
this.label1.AccessibleName = resources.GetString("label1.AccessibleName");
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("label1.Anchor")));
this.label1.AutoSize = ((bool)(resources.GetObject("label1.AutoSize")));
this.label1.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("label1.Dock")));
this.label1.Enabled = ((bool)(resources.GetObject("label1.Enabled")));
this.label1.Font = ((System.Drawing.Font)(resources.GetObject("label1.Font")));
this.label1.Image = ((System.Drawing.Image)(resources.GetObject("label1.Image")));
this.label1.ImageAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("label1.ImageAlign")));
this.label1.ImageIndex = ((int)(resources.GetObject("label1.ImageIndex")));
this.label1.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("label1.ImeMode")));
this.label1.Location = ((System.Drawing.Point)(resources.GetObject("label1.Location")));
this.label1.Name = "label1";
this.label1.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("label1.RightToLeft")));
this.label1.Size = ((System.Drawing.Size)(resources.GetObject("label1.Size")));
this.label1.TabIndex = ((int)(resources.GetObject("label1.TabIndex")));
this.label1.Text = resources.GetString("label1.Text");
this.label1.TextAlign = ((System.Drawing.ContentAlignment)(resources.GetObject("label1.TextAlign")));
this.label1.Visible = ((bool)(resources.GetObject("label1.Visible")));
//
// Form1
//
this.AccessibleDescription = resources.GetString("$this.AccessibleDescription");
this.AccessibleName = resources.GetString("$this.AccessibleName");
this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
this.Controls.Add(this.label1);
this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
this.Name = "Form1";
this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
this.Text = resources.GetString("$this.Text");
this.ResumeLayout(false);
Vad är det här egentligen, mera MS bloatware? Jag har ju förståelse för att det är mer komplicerat när man inte vet innan hur stort utrymme texten tar osv, men jag tycker det ser onödigt komplicerat ut för en enda label.
Vilka alternativ finns förutom att skriva en helt egen lösning? Jag har funderat lite på XML. Men då får man ju använda en färdig lösning typ SCEW, se http://www.nongnu.org/scew.
/Roland