# HG changeset patch # User IBBoard # Date 1261342768 0 # Node ID ece26f6a62f397e45ba5af85332efd7dc93974e5 # Parent bf4f04f385d0209cb67ce5bfea1bc77b2a66ee52 Re #223: Use translations within the API * Translate headings in basic HTML output * Remove some translation of exception messages (exceptions are for developers, users should get a message built from exception message) * Replace a string concat with String.Format Still need to check Requirements and below diff -r bf4f04f385d0 -r ece26f6a62f3 api/Exporters/WarFoundryHtmlExporter.cs --- a/api/Exporters/WarFoundryHtmlExporter.cs Sun Dec 20 20:28:14 2009 +0000 +++ b/api/Exporters/WarFoundryHtmlExporter.cs Sun Dec 20 20:59:28 2009 +0000 @@ -108,7 +108,7 @@ XmlElement headerRow = doc.CreateElement("tr"); table.AppendChild(headerRow); XmlElement name = doc.CreateElement("th"); - name.InnerText = "Name"; + name.InnerText = Translation.GetTranslation("armyHtmlOutputTableHeaderUnitName", "name"); headerRow.AppendChild(name); foreach (StatSlot stat in stats.StatSlots) @@ -119,11 +119,11 @@ } XmlElement notes = doc.CreateElement("th"); - notes.InnerText = "Notes"; + notes.InnerText = Translation.GetTranslation("armyHtmlOutputTableHeaderUnitNotes", "name");; headerRow.AppendChild(notes); XmlElement points = doc.CreateElement("th"); - points.InnerText = "Points"; + points.InnerText = Translation.GetTranslation("armyHtmlOutputTableHeaderUnitPoints", "name");; headerRow.AppendChild(points); return table; @@ -179,7 +179,7 @@ } else { - amountString = amount.ToString(); + amountString = Translation.GetTranslation("armyHtmlExportEquipAmountNumber", "{0}", amount); } sb.Append(Translation.GetTranslation("armyHtmlExportEquipAmountRatio", "{0} for {1}", equip.Name, amountString)); diff -r bf4f04f385d0 -r ece26f6a62f3 api/Objects/InvalidContainershipException.cs --- a/api/Objects/InvalidContainershipException.cs Sun Dec 20 20:28:14 2009 +0000 +++ b/api/Objects/InvalidContainershipException.cs Sun Dec 20 20:59:28 2009 +0000 @@ -3,6 +3,7 @@ // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. using System; +using IBBoard.Lang; namespace IBBoard.WarFoundry.API.Objects { @@ -23,7 +24,7 @@ private static string CreateMessageString(Unit containingUnit, Unit containedUnit) { - return containingUnit.Name+" cannot contain "+containedUnit.Name+" because units of "+containingUnit.UnitType.Name+" cannot contain units of "+containedUnit.UnitType.Name; + return String.Format("{0} cannot contain {1} because units of type {2} cannot contain units of type {3}", containingUnit.Name, containedUnit.Name, containingUnit.UnitType.Name, containedUnit.UnitType.Name); } /// diff -r bf4f04f385d0 -r ece26f6a62f3 api/Objects/Stats.cs --- a/api/Objects/Stats.cs Sun Dec 20 20:28:14 2009 +0000 +++ b/api/Objects/Stats.cs Sun Dec 20 20:59:28 2009 +0000 @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; -using IBBoard.Lang; namespace IBBoard.WarFoundry.API.Objects { @@ -62,7 +61,7 @@ } catch (ArgumentException ex) { - throw new ArgumentException(Translation.GetTranslation("InvalidStatPos", "Invalid statistic ID {0} for stats based on system stats set {1}", new object[]{id, sysStats.ID}), ex); + throw new ArgumentException(String.Format("Invalid statistic ID {0} for stats based on system stats set {1}", new object[]{id, sysStats.ID}), ex); } return stat; @@ -79,7 +78,7 @@ } else { - throw new ArgumentException(Translation.GetTranslation("InvalidStatPos", "Invalid statistic position {0} for stats based on system stats set {1}", new object[]{pos, sysStats.ID})); + throw new ArgumentException(String.Format("Invalid statistic position {0} for stats based on system stats set {1}", new object[]{pos, sysStats.ID})); } } } diff -r bf4f04f385d0 -r ece26f6a62f3 api/Objects/UnitEquipmentRatioSelection.cs --- a/api/Objects/UnitEquipmentRatioSelection.cs Sun Dec 20 20:28:14 2009 +0000 +++ b/api/Objects/UnitEquipmentRatioSelection.cs Sun Dec 20 20:59:28 2009 +0000 @@ -53,7 +53,7 @@ if (amount == 100) { - amountString = "all"; //TODO: Translate + amountString = "all"; } else {