Mercurial > repos > snowblizz-super-API-ideas
changeset 228:ece26f6a62f3
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
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 20 Dec 2009 20:59:28 +0000 |
parents | bf4f04f385d0 |
children | 6083010a005c |
files | api/Exporters/WarFoundryHtmlExporter.cs api/Objects/InvalidContainershipException.cs api/Objects/Stats.cs api/Objects/UnitEquipmentRatioSelection.cs |
diffstat | 4 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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));
--- 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); } /// <value>
--- 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})); } } }