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 diff
     1.1 --- a/FrmNewUnit.cs	Wed Dec 29 19:54:00 2010 +0000
     1.2 +++ b/FrmNewUnit.cs	Wed Dec 29 20:56:03 2010 +0000
     1.3 @@ -9,6 +9,7 @@
     1.4  using IBBoard.WarFoundry.API.Objects;
     1.5  using IBBoard.WarFoundry.API.Requirements;
     1.6  using log4net;
     1.7 +using IBBoard.Lang;
     1.8  
     1.9  namespace IBBoard.WarFoundry.GUI.GTK
    1.10  {
    1.11 @@ -17,14 +18,15 @@
    1.12  		private ILog logger = LogManager.GetLogger(typeof(FrmNewUnit));
    1.13  		private UnitType unitType;
    1.14  		private Army unitArmy;
    1.15 +		private Category cat;
    1.16  
    1.17 -		public FrmNewUnit(Race race, Category cat, Army army)
    1.18 +		public FrmNewUnit(Race race, Category category, Army army)
    1.19  		{
    1.20  			this.Build();
    1.21  			unitArmy = army;
    1.22 +			cat = category;
    1.23  			
    1.24  			TreeViewColumn unitTypeColumn = new TreeViewColumn();
    1.25 -			unitTypeColumn.Title = "Unit Type";
    1.26  			CellRendererText unitTypeCell = new CellRendererText();
    1.27  			unitTypeColumn.PackStart(unitTypeCell, true);
    1.28  			lstUnitTypes.AppendColumn(unitTypeColumn);
    1.29 @@ -41,6 +43,15 @@
    1.30  			
    1.31  			lstUnitTypes.Model = store;
    1.32  			lstUnitTypes.Selection.Changed += new EventHandler(OnSelectionChanged);
    1.33 +			Translate();
    1.34 +		}
    1.35 +
    1.36 +		protected override void Translate()
    1.37 +		{
    1.38 +			base.Translate();
    1.39 +			lstUnitTypes.Columns[0].Title = Translation.GetTranslation("frmNewUnitNewUnitColumn", "unit type");
    1.40 +			Title = Translation.GetTranslation(Name, "Create new unit", cat.Name);
    1.41 +			ControlTranslator.TranslateButtons(bttnCreate, bttnCancel);
    1.42  		}
    1.43  
    1.44  		private void RenderUnitTypeName(TreeViewColumn column, CellRenderer cell, TreeModel model, TreeIter iter)
    1.45 @@ -80,7 +91,7 @@
    1.46  			
    1.47  			if (type != null)
    1.48  			{
    1.49 -				buttonOk.Sensitive = true;
    1.50 +				bttnCreate.Sensitive = true;
    1.51  				List<FailedUnitRequirement> fails = unitArmy.CanAddUnitType(type);
    1.52  				lblNewUnitWarning.Visible = (fails != null);
    1.53  
    1.54 @@ -92,7 +103,7 @@
    1.55  			}
    1.56  			else
    1.57  			{
    1.58 -				buttonOk.Sensitive = false;
    1.59 +				bttnCreate.Sensitive = false;
    1.60  				lblNewUnitWarning.Visible = false;
    1.61  			}
    1.62  		}
     2.1 --- a/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmNewUnit.cs	Wed Dec 29 19:54:00 2010 +0000
     2.2 +++ b/gtk-gui/IBBoard.WarFoundry.GUI.GTK.FrmNewUnit.cs	Wed Dec 29 20:56:03 2010 +0000
     2.3 @@ -6,12 +6,12 @@
     2.4  	{
     2.5  		private global::Gtk.VBox vbox2;
     2.6  		private global::Gtk.HBox hbox1;
     2.7 -		private global::Gtk.Label label1;
     2.8 +		private global::IBBoard.GtkSharp.Translatable.TranslatableLabel lblUnitType;
     2.9  		private global::Gtk.ScrolledWindow GtkScrolledWindow;
    2.10  		private global::Gtk.TreeView lstUnitTypes;
    2.11  		private global::Gtk.Label lblNewUnitWarning;
    2.12 -		private global::Gtk.Button buttonCancel;
    2.13 -		private global::Gtk.Button buttonOk;
    2.14 +		private global::Gtk.Button bttnCancel;
    2.15 +		private global::Gtk.Button bttnCreate;
    2.16  
    2.17  		protected virtual void Build()
    2.18  		{
    2.19 @@ -37,11 +37,11 @@
    2.20  			this.hbox1.Name = "hbox1";
    2.21  			this.hbox1.Spacing = 6;
    2.22  			// Container child hbox1.Gtk.Box+BoxChild
    2.23 -			this.label1 = new global::Gtk.Label();
    2.24 -			this.label1.Name = "label1";
    2.25 -			this.label1.LabelProp = global::Mono.Unix.Catalog.GetString("Unit Type:");
    2.26 -			this.hbox1.Add(this.label1);
    2.27 -			global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.label1]));
    2.28 +			this.lblUnitType = new global::IBBoard.GtkSharp.Translatable.TranslatableLabel();
    2.29 +			this.lblUnitType.Name = "lblUnitType";
    2.30 +			this.lblUnitType.LabelProp = global::Mono.Unix.Catalog.GetString("unit type");
    2.31 +			this.hbox1.Add(this.lblUnitType);
    2.32 +			global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.lblUnitType]));
    2.33  			w2.Position = 0;
    2.34  			w2.Expand = false;
    2.35  			w2.Fill = false;
    2.36 @@ -86,28 +86,28 @@
    2.37  			w8.BorderWidth = ((uint)(5));
    2.38  			w8.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
    2.39  			// Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
    2.40 -			this.buttonCancel = new global::Gtk.Button();
    2.41 -			this.buttonCancel.CanDefault = true;
    2.42 -			this.buttonCancel.CanFocus = true;
    2.43 -			this.buttonCancel.Name = "buttonCancel";
    2.44 -			this.buttonCancel.UseStock = true;
    2.45 -			this.buttonCancel.UseUnderline = true;
    2.46 -			this.buttonCancel.Label = "gtk-cancel";
    2.47 -			this.AddActionWidget(this.buttonCancel, -6);
    2.48 -			global::Gtk.ButtonBox.ButtonBoxChild w9 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w8[this.buttonCancel]));
    2.49 +			this.bttnCancel = new global::Gtk.Button();
    2.50 +			this.bttnCancel.CanDefault = true;
    2.51 +			this.bttnCancel.CanFocus = true;
    2.52 +			this.bttnCancel.Name = "bttnCancel";
    2.53 +			this.bttnCancel.UseStock = true;
    2.54 +			this.bttnCancel.UseUnderline = true;
    2.55 +			this.bttnCancel.Label = "gtk-cancel";
    2.56 +			this.AddActionWidget(this.bttnCancel, -6);
    2.57 +			global::Gtk.ButtonBox.ButtonBoxChild w9 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w8[this.bttnCancel]));
    2.58  			w9.Expand = false;
    2.59  			w9.Fill = false;
    2.60  			// Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
    2.61 -			this.buttonOk = new global::Gtk.Button();
    2.62 -			this.buttonOk.Sensitive = false;
    2.63 -			this.buttonOk.CanDefault = true;
    2.64 -			this.buttonOk.CanFocus = true;
    2.65 -			this.buttonOk.Name = "buttonOk";
    2.66 -			this.buttonOk.UseStock = true;
    2.67 -			this.buttonOk.UseUnderline = true;
    2.68 -			this.buttonOk.Label = "gtk-ok";
    2.69 -			this.AddActionWidget(this.buttonOk, -5);
    2.70 -			global::Gtk.ButtonBox.ButtonBoxChild w10 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w8[this.buttonOk]));
    2.71 +			this.bttnCreate = new global::Gtk.Button();
    2.72 +			this.bttnCreate.Sensitive = false;
    2.73 +			this.bttnCreate.CanDefault = true;
    2.74 +			this.bttnCreate.CanFocus = true;
    2.75 +			this.bttnCreate.Name = "bttnCreate";
    2.76 +			this.bttnCreate.UseStock = true;
    2.77 +			this.bttnCreate.UseUnderline = true;
    2.78 +			this.bttnCreate.Label = "gtk-ok";
    2.79 +			this.AddActionWidget(this.bttnCreate, -5);
    2.80 +			global::Gtk.ButtonBox.ButtonBoxChild w10 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w8[this.bttnCreate]));
    2.81  			w10.Position = 1;
    2.82  			w10.Expand = false;
    2.83  			w10.Fill = false;
    2.84 @@ -119,8 +119,8 @@
    2.85  			this.DefaultHeight = 318;
    2.86  			this.Show();
    2.87  			this.lstUnitTypes.RowActivated += new global::Gtk.RowActivatedHandler(this.OnRowActivated);
    2.88 -			this.buttonCancel.Activated += new global::System.EventHandler(this.OnButtonCancelActivated);
    2.89 -			this.buttonOk.Clicked += new global::System.EventHandler(this.OnButtonOkClicked);
    2.90 +			this.bttnCancel.Activated += new global::System.EventHandler(this.OnButtonCancelActivated);
    2.91 +			this.bttnCreate.Clicked += new global::System.EventHandler(this.OnButtonOkClicked);
    2.92  		}
    2.93  	}
    2.94  }
     3.1 --- a/gtk-gui/gui.stetic	Wed Dec 29 19:54:00 2010 +0000
     3.2 +++ b/gtk-gui/gui.stetic	Wed Dec 29 20:56:03 2010 +0000
     3.3 @@ -575,9 +575,9 @@
     3.4                  <property name="MemberName" />
     3.5                  <property name="Spacing">6</property>
     3.6                  <child>
     3.7 -                  <widget class="Gtk.Label" id="label1">
     3.8 +                  <widget class="IBBoard.GtkSharp.Translatable.TranslatableLabel" id="lblUnitType">
     3.9                      <property name="MemberName" />
    3.10 -                    <property name="LabelProp" translatable="yes">Unit Type:</property>
    3.11 +                    <property name="LabelProp" translatable="yes">unit type</property>
    3.12                    </widget>
    3.13                    <packing>
    3.14                      <property name="Position">0</property>
    3.15 @@ -645,7 +645,7 @@
    3.16          <property name="Size">2</property>
    3.17          <property name="LayoutStyle">End</property>
    3.18          <child>
    3.19 -          <widget class="Gtk.Button" id="buttonCancel">
    3.20 +          <widget class="Gtk.Button" id="bttnCancel">
    3.21              <property name="MemberName" />
    3.22              <property name="CanDefault">True</property>
    3.23              <property name="CanFocus">True</property>
    3.24 @@ -662,7 +662,7 @@
    3.25            </packing>
    3.26          </child>
    3.27          <child>
    3.28 -          <widget class="Gtk.Button" id="buttonOk">
    3.29 +          <widget class="Gtk.Button" id="bttnCreate">
    3.30              <property name="MemberName" />
    3.31              <property name="Sensitive">False</property>
    3.32              <property name="CanDefault">True</property>
     4.1 --- a/translations/en.translation	Wed Dec 29 19:54:00 2010 +0000
     4.2 +++ b/translations/en.translation	Wed Dec 29 20:56:03 2010 +0000
     4.3 @@ -30,7 +30,7 @@
     4.4  <translation id="lblRaceList">Races:</translation>
     4.5  <translation id="lblArmyName">Army name:</translation>
     4.6  <translation id="lblArmySize">Army size:</translation>
     4.7 -<translation id="bttnCreate">Create army</translation>
     4.8 +<translation id="bttnCreate">Create</translation>
     4.9  <translation id="bttnCancel">Cancel</translation>
    4.10  <translation id="bttnSelectUnit">Create unit</translation>
    4.11  <translation id="lblUnitList">Unit types:</translation>
    4.12 @@ -41,6 +41,8 @@
    4.13  <translation id="IBBoard.WarFoundry.GUI.GTK.FrmNewArmy">Create Army</translation>	
    4.14  <translation id="frmNewArmyRaceColumn">Race</translation>
    4.15  <translation id="IBBoard.WarFoundry.GUI.GTK.FrmNewUnit">Add New {0} Choice</translation>
    4.16 +<translation id="frmNewUnitNewUnitColumn">Unit Type</translation>
    4.17 +<translation id="lblUnitType">Unit Type:</translation>
    4.18  <translation id="IBBoard.WarFoundry.GUI.GTK.FrmAbout">About WarFoundry</translation>
    4.19  <translation id="exportBasicHtmlDialogTitle">Export army</translation>
    4.20  <translation id="exportBasicHtmlCancel">Cancel</translation>