Mercurial > repos > IBBoard.WarFoundry.GUI.GTK
changeset 88:b0089e875754
Re #308: Make GTK# UI translatable
* Make FrmNewUnit translatable
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 29 Dec 2010 20:56:03 +0000 |
parents | 40857cfb309b |
children | 31d54f67d50d |
files | FrmNewUnit.cs gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmNewUnit.cs gtk-gui/gui.stetic translations/en.translation |
diffstat | 4 files changed, 51 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/FrmNewUnit.cs Wed Dec 29 19:54:00 2010 +0000 +++ b/FrmNewUnit.cs Wed Dec 29 20:56:03 2010 +0000 @@ -9,6 +9,7 @@ using IBBoard.WarFoundry.API.Objects; using IBBoard.WarFoundry.API.Requirements; using log4net; +using IBBoard.Lang; namespace IBBoard.WarFoundry.GUI.GTK { @@ -17,14 +18,15 @@ private ILog logger = LogManager.GetLogger(typeof(FrmNewUnit)); private UnitType unitType; private Army unitArmy; + private Category cat; - public FrmNewUnit(Race race, Category cat, Army army) + public FrmNewUnit(Race race, Category category, Army army) { this.Build(); unitArmy = army; + cat = category; TreeViewColumn unitTypeColumn = new TreeViewColumn(); - unitTypeColumn.Title = "Unit Type"; CellRendererText unitTypeCell = new CellRendererText(); unitTypeColumn.PackStart(unitTypeCell, true); lstUnitTypes.AppendColumn(unitTypeColumn); @@ -41,6 +43,15 @@ lstUnitTypes.Model = store; lstUnitTypes.Selection.Changed += new EventHandler(OnSelectionChanged); + Translate(); + } + + protected override void Translate() + { + base.Translate(); + lstUnitTypes.Columns[0].Title = Translation.GetTranslation("frmNewUnitNewUnitColumn", "unit type"); + Title = Translation.GetTranslation(Name, "Create new unit", cat.Name); + ControlTranslator.TranslateButtons(bttnCreate, bttnCancel); } private void RenderUnitTypeName(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter) @@ -80,7 +91,7 @@ if (type != null) { - buttonOk.Sensitive = true; + bttnCreate.Sensitive = true; List<FailedUnitRequirement> fails = unitArmy.CanAddUnitType(type); lblNewUnitWarning.Visible = (fails != null); @@ -92,7 +103,7 @@ } else { - buttonOk.Sensitive = false; + bttnCreate.Sensitive = false; lblNewUnitWarning.Visible = false; } }
--- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmNewUnit.cs Wed Dec 29 19:54:00 2010 +0000 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmNewUnit.cs Wed Dec 29 20:56:03 2010 +0000 @@ -6,12 +6,12 @@ { private global::Gtk.VBox vbox2; private global::Gtk.HBox hbox1; - private global::Gtk.Label label1; + private global::IBBoard.GtkSharp.Translatable.TranslatableLabel lblUnitType; private global::Gtk.ScrolledWindow GtkScrolledWindow; private global::Gtk.TreeView lstUnitTypes; private global::Gtk.Label lblNewUnitWarning; - private global::Gtk.Button buttonCancel; - private global::Gtk.Button buttonOk; + private global::Gtk.Button bttnCancel; + private global::Gtk.Button bttnCreate; protected virtual void Build() { @@ -37,11 +37,11 @@ this.hbox1.Name = "hbox1"; this.hbox1.Spacing = 6; // Container child hbox1.Gtk.Box+BoxChild - this.label1 = new global::Gtk.Label(); - this.label1.Name = "label1"; - this.label1.LabelProp = global::Mono.Unix.Catalog.GetString("Unit Type:"); - this.hbox1.Add(this.label1); - global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.label1])); + this.lblUnitType = new global::IBBoard.GtkSharp.Translatable.TranslatableLabel(); + this.lblUnitType.Name = "lblUnitType"; + this.lblUnitType.LabelProp = global::Mono.Unix.Catalog.GetString("unit type"); + this.hbox1.Add(this.lblUnitType); + global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.lblUnitType])); w2.Position = 0; w2.Expand = false; w2.Fill = false; @@ -86,28 +86,28 @@ w8.BorderWidth = ((uint)(5)); w8.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4)); // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild - this.buttonCancel = new global::Gtk.Button(); - this.buttonCancel.CanDefault = true; - this.buttonCancel.CanFocus = true; - this.buttonCancel.Name = "buttonCancel"; - this.buttonCancel.UseStock = true; - this.buttonCancel.UseUnderline = true; - this.buttonCancel.Label = "gtk-cancel"; - this.AddActionWidget(this.buttonCancel, -6); - global::Gtk.ButtonBox.ButtonBoxChild w9 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w8[this.buttonCancel])); + this.bttnCancel = new global::Gtk.Button(); + this.bttnCancel.CanDefault = true; + this.bttnCancel.CanFocus = true; + this.bttnCancel.Name = "bttnCancel"; + this.bttnCancel.UseStock = true; + this.bttnCancel.UseUnderline = true; + this.bttnCancel.Label = "gtk-cancel"; + this.AddActionWidget(this.bttnCancel, -6); + global::Gtk.ButtonBox.ButtonBoxChild w9 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w8[this.bttnCancel])); w9.Expand = false; w9.Fill = false; // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild - this.buttonOk = new global::Gtk.Button(); - this.buttonOk.Sensitive = false; - this.buttonOk.CanDefault = true; - this.buttonOk.CanFocus = true; - this.buttonOk.Name = "buttonOk"; - this.buttonOk.UseStock = true; - this.buttonOk.UseUnderline = true; - this.buttonOk.Label = "gtk-ok"; - this.AddActionWidget(this.buttonOk, -5); - global::Gtk.ButtonBox.ButtonBoxChild w10 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w8[this.buttonOk])); + this.bttnCreate = new global::Gtk.Button(); + this.bttnCreate.Sensitive = false; + this.bttnCreate.CanDefault = true; + this.bttnCreate.CanFocus = true; + this.bttnCreate.Name = "bttnCreate"; + this.bttnCreate.UseStock = true; + this.bttnCreate.UseUnderline = true; + this.bttnCreate.Label = "gtk-ok"; + this.AddActionWidget(this.bttnCreate, -5); + global::Gtk.ButtonBox.ButtonBoxChild w10 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w8[this.bttnCreate])); w10.Position = 1; w10.Expand = false; w10.Fill = false; @@ -119,8 +119,8 @@ this.DefaultHeight = 318; this.Show(); this.lstUnitTypes.RowActivated += new global::Gtk.RowActivatedHandler(this.OnRowActivated); - this.buttonCancel.Activated += new global::System.EventHandler(this.OnButtonCancelActivated); - this.buttonOk.Clicked += new global::System.EventHandler(this.OnButtonOkClicked); + this.bttnCancel.Activated += new global::System.EventHandler(this.OnButtonCancelActivated); + this.bttnCreate.Clicked += new global::System.EventHandler(this.OnButtonOkClicked); } } }
--- a/gtk-gui/gui.stetic Wed Dec 29 19:54:00 2010 +0000 +++ b/gtk-gui/gui.stetic Wed Dec 29 20:56:03 2010 +0000 @@ -575,9 +575,9 @@ <property name="MemberName" /> <property name="Spacing">6</property> <child> - <widget class="Gtk.Label" id="label1"> + <widget class="IBBoard.GtkSharp.Translatable.TranslatableLabel" id="lblUnitType"> <property name="MemberName" /> - <property name="LabelProp" translatable="yes">Unit Type:</property> + <property name="LabelProp" translatable="yes">unit type</property> </widget> <packing> <property name="Position">0</property> @@ -645,7 +645,7 @@ <property name="Size">2</property> <property name="LayoutStyle">End</property> <child> - <widget class="Gtk.Button" id="buttonCancel"> + <widget class="Gtk.Button" id="bttnCancel"> <property name="MemberName" /> <property name="CanDefault">True</property> <property name="CanFocus">True</property> @@ -662,7 +662,7 @@ </packing> </child> <child> - <widget class="Gtk.Button" id="buttonOk"> + <widget class="Gtk.Button" id="bttnCreate"> <property name="MemberName" /> <property name="Sensitive">False</property> <property name="CanDefault">True</property>
--- a/translations/en.translation Wed Dec 29 19:54:00 2010 +0000 +++ b/translations/en.translation Wed Dec 29 20:56:03 2010 +0000 @@ -30,7 +30,7 @@ <translation id="lblRaceList">Races:</translation> <translation id="lblArmyName">Army name:</translation> <translation id="lblArmySize">Army size:</translation> -<translation id="bttnCreate">Create army</translation> +<translation id="bttnCreate">Create</translation> <translation id="bttnCancel">Cancel</translation> <translation id="bttnSelectUnit">Create unit</translation> <translation id="lblUnitList">Unit types:</translation> @@ -41,6 +41,8 @@ <translation id="IBBoard.WarFoundry.GUI.GTK.FrmNewArmy">Create Army</translation> <translation id="frmNewArmyRaceColumn">Race</translation> <translation id="IBBoard.WarFoundry.GUI.GTK.FrmNewUnit">Add New {0} Choice</translation> +<translation id="frmNewUnitNewUnitColumn">Unit Type</translation> +<translation id="lblUnitType">Unit Type:</translation> <translation id="IBBoard.WarFoundry.GUI.GTK.FrmAbout">About WarFoundry</translation> <translation id="exportBasicHtmlDialogTitle">Export army</translation> <translation id="exportBasicHtmlCancel">Cancel</translation>