changeset 219:a3e62a2c267f xml-export-ui

Added translation support for exceptional cases
author Dan.Kulinski@dank-laptop.Global.Local
date Wed, 24 Aug 2011 08:07:18 -0600
parents 83685ed69c69
children e10688b29092
files FrmXmlExport.cs translations/de.translation translations/en.translation translations/fi.translation translations/fr.translation translations/it.translation translations/nl.translation translations/ru.translation translations/sv.translation
diffstat 9 files changed, 77 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/FrmXmlExport.cs	Mon Aug 22 17:20:05 2011 -0600
+++ b/FrmXmlExport.cs	Wed Aug 24 08:07:18 2011 -0600
@@ -8,8 +8,10 @@
 using System.IO;
 using System.Windows.Forms;
 using System.Xml.Xsl;
+using IBBoard.Lang;
 using IBBoard.WarFoundry.API.Objects;
 using IBBoard.WarFoundry.API.Exporters;
+using System.Xml.Xsl;
 
 namespace IBBoard.WarFoundry.GUI.WinForms
 {
@@ -27,11 +29,6 @@
             tbXslPath.Text = Directory.GetCurrentDirectory() + "\\xsl\\default_html.xsl";
         }
 
-        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
-        {
-
-        }
-
         private void bttnOutputSelect_Click(object sender, EventArgs e)
         {
             SaveFileDialog sfd = new SaveFileDialog();
@@ -53,22 +50,49 @@
 
         private void bttnExport_Click(object sender, EventArgs e)
         {
-            if (cbApplyTransform.Checked)
+            string errorMessage = "";
+            // Catch potential errors with the file export or XSL compiliation
+            try
             {
-                try
+                if (cbApplyTransform.Checked)
                 {
                     WarFoundryXmlWithXslExporter.GetDefault().ExportArmyWithTransform(myArmy, tbOutputFile.Text, tbXslPath.Text);
                 }
-                catch (Exception ex)
+                else
                 {
-                    MessageBox.Show(this, "Sorry, but an error occurred during export.", "Error on export", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
+                    WarFoundryXmlWithXslExporter.GetDefault().ExportArmy(myArmy, tbOutputFile.Text);
                 }
             }
-            else
+            catch (XsltCompileException ex)
+            {
+                errorMessage = Translation.GetTranslation("mbErrorCompileFailed", "") + 
+                    ":\n" + ex.Message;
+            }
+            catch (XsltException ex)
+            {
+
+                errorMessage = Translation.GetTranslation("mbErrorXSLTFailed", "") +
+                    ":\n" + ex.Message;
+            }
+            catch (FileNotFoundException ex)
             {
-                WarFoundryXmlWithXslExporter.GetDefault().ExportArmy(myArmy, tbOutputFile.Text);
+                errorMessage = Translation.GetTranslation("mbErrorFileNotFoundFailed", "") +
+                    ":\n" + ex.Message;
+            }
+            catch (IOException ex)
+            {
+                errorMessage = Translation.GetTranslation("mbErrorIOFailed", "") +
+                    ":\n" + ex.Message;
             }
-            
+            catch (Exception ex)
+            {
+                errorMessage = Translation.GetTranslation("mbErrorFailed", "") +
+                    ":\n" + ex.Message;
+            }
+            if (errorMessage != "")
+            {
+                MessageBox.Show(errorMessage, "Error During Export", MessageBoxButtons.OK, MessageBoxIcon.Error);
+            }
             this.DialogResult = DialogResult.OK;
             this.Hide();
         }
--- a/translations/de.translation	Mon Aug 22 17:20:05 2011 -0600
+++ b/translations/de.translation	Wed Aug 24 08:07:18 2011 -0600
@@ -122,5 +122,10 @@
 	<translation id="FrmPreferences">Einstellungen</translation>
 	<translation id="languagePrefSection">Sprache</translation>
 	<translation id="lblLanguage">Sprache:</translation>
-	<translation id="languagesGroup">Sprache</translation>	
+	<translation id="languagesGroup">Sprache</translation>
+  <translation id="mbErrorCompileFailed">Failed to compile XSL translation</translation>
+  <translation id="mbErrorXSLTFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorFileNotFoundFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorIOFailed">Failed to output file</translation>
+  <translation id="mbErrorFailed">Failed to export</translation>
 </translations>
\ No newline at end of file
--- a/translations/en.translation	Mon Aug 22 17:20:05 2011 -0600
+++ b/translations/en.translation	Wed Aug 24 08:07:18 2011 -0600
@@ -132,4 +132,9 @@
   <translation id="treeNodeText">{0} ({1} {2})</translation>
   <translation id="setUnitEquipmentItemName">( {0} {1} each)</translation>
   <translation id="FailedRequirementMessage">Army Requirement Failures</translation>
+  <translation id="mbErrorCompileFailed">Failed to compile XSL translation</translation>
+  <translation id="mbErrorXSLTFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorFileNotFoundFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorIOFailed">Failed to output file</translation>
+  <translation id="mbErrorFailed">Failed to export</translation>
 </translations>
\ No newline at end of file
--- a/translations/fi.translation	Mon Aug 22 17:20:05 2011 -0600
+++ b/translations/fi.translation	Wed Aug 24 08:07:18 2011 -0600
@@ -124,6 +124,11 @@
 	<translation id="lblLanguage">Kieli:</translation>
 	<translation id="languagesGroup">Kieli</translation>
   <translation id="GameSystemFilesReloaded">Pelisysteemi ja rotutiedostot ovat ladatut.</translation>
+  <translation id="mbErrorCompileFailed">Failed to compile XSL translation</translation>
+  <translation id="mbErrorXSLTFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorFileNotFoundFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorIOFailed">Failed to output file</translation>
+  <translation id="mbErrorFailed">Failed to export</translation>
 </translations>
 
 
--- a/translations/fr.translation	Mon Aug 22 17:20:05 2011 -0600
+++ b/translations/fr.translation	Wed Aug 24 08:07:18 2011 -0600
@@ -109,4 +109,9 @@
 	<translation id="requirementUnitTypeAtLeastSingle">{1} {0}</translation>
 	<translation id="requirementUnitTypeAtLeastJoiner">{0}, {1}</translation>
 	<translation id="requirementUnitTypeAtLeast">{0} peut être sélectionné seulement si l'objet suivant est sélectionné : {1}</translation>
+  <translation id="mbErrorCompileFailed">Failed to compile XSL translation</translation>
+  <translation id="mbErrorXSLTFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorFileNotFoundFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorIOFailed">Failed to output file</translation>
+  <translation id="mbErrorFailed">Failed to export</translation>
 </translations>
\ No newline at end of file
--- a/translations/it.translation	Mon Aug 22 17:20:05 2011 -0600
+++ b/translations/it.translation	Wed Aug 24 08:07:18 2011 -0600
@@ -123,4 +123,9 @@
 	<translation id="languagePrefSection">Lingua</translation>
 	<translation id="lblLanguage">Lingua:</translation>
 	<translation id="languagesGroup">Lingua</translation>
+  <translation id="mbErrorCompileFailed">Failed to compile XSL translation</translation>
+  <translation id="mbErrorXSLTFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorFileNotFoundFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorIOFailed">Failed to output file</translation>
+  <translation id="mbErrorFailed">Failed to export</translation>
 </translations>
\ No newline at end of file
--- a/translations/nl.translation	Mon Aug 22 17:20:05 2011 -0600
+++ b/translations/nl.translation	Wed Aug 24 08:07:18 2011 -0600
@@ -108,4 +108,9 @@
 	<translation id="requirementUnitTypeAtLeastSingle">{1} {0}</translation>
 	<translation id="requirementUnitTypeAtLeastJoiner">{0}, {1}</translation>
 	<translation id="requirementUnitTypeAtLeast">{0} kan alleen gekozen worden als een van de volgende dingen genomen is: {1}</translation>
+  <translation id="mbErrorCompileFailed">Failed to compile XSL translation</translation>
+  <translation id="mbErrorXSLTFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorFileNotFoundFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorIOFailed">Failed to output file</translation>
+  <translation id="mbErrorFailed">Failed to export</translation>
 </translations>
\ No newline at end of file
--- a/translations/ru.translation	Mon Aug 22 17:20:05 2011 -0600
+++ b/translations/ru.translation	Wed Aug 24 08:07:18 2011 -0600
@@ -94,4 +94,9 @@
 	<translation id="setUnitNameCommandUndoDescription">Поменять название "{0}" на "{1}"</translation>
 	<translation id="setUnitSizeCommandDescription">Сделать размер {0} - {1}</translation>
 	<translation id="setUnitSizeCommandUndoDescription">Сделать размер {0} - {1}</translation>
+  <translation id="mbErrorCompileFailed">Failed to compile XSL translation</translation>
+  <translation id="mbErrorXSLTFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorFileNotFoundFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorIOFailed">Failed to output file</translation>
+  <translation id="mbErrorFailed">Failed to export</translation>
 </translations>
\ No newline at end of file
--- a/translations/sv.translation	Mon Aug 22 17:20:05 2011 -0600
+++ b/translations/sv.translation	Wed Aug 24 08:07:18 2011 -0600
@@ -131,5 +131,9 @@
 	<translation id="statusPanelPointsToolTip">Aktuellt poängvärde för armé</translation>
 	<translation id="treeNodeText">{0} ({1} {2})</translation>
   <translation id="setUnitEquipmentItemName">( {0} {1} var)</translation>
-  
+  <translation id="mbErrorCompileFailed">Failed to compile XSL translation</translation>
+  <translation id="mbErrorXSLTFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorFileNotFoundFailed">Failed to load XSL translation</translation>
+  <translation id="mbErrorIOFailed">Failed to output file</translation>
+  <translation id="mbErrorFailed">Failed to export</translation>
 </translations>