diff --git a/SafeExamBrowser.Core.UnitTests/I18n/Text_Valid.xml b/SafeExamBrowser.Core.UnitTests/I18n/Text_Valid.xml
index def6f21a..1e263814 100644
--- a/SafeExamBrowser.Core.UnitTests/I18n/Text_Valid.xml
+++ b/SafeExamBrowser.Core.UnitTests/I18n/Text_Valid.xml
@@ -1,5 +1,9 @@
- Application Log
- Version
+ Application Log
+ Version
+
+ Hello world
+
+
\ No newline at end of file
diff --git a/SafeExamBrowser.Core.UnitTests/I18n/XmlTextResourceTests.cs b/SafeExamBrowser.Core.UnitTests/I18n/XmlTextResourceTests.cs
index a3a2d75b..b3f7140a 100644
--- a/SafeExamBrowser.Core.UnitTests/I18n/XmlTextResourceTests.cs
+++ b/SafeExamBrowser.Core.UnitTests/I18n/XmlTextResourceTests.cs
@@ -29,7 +29,7 @@ namespace SafeExamBrowser.Core.UnitTests.I18n
var text = sut.LoadText();
Assert.IsNotNull(text);
- Assert.IsTrue(text.Count == 2);
+ Assert.IsTrue(text.Count == 4);
Assert.AreEqual("Application Log", text[TextKey.LogWindow_Title]);
Assert.AreEqual("Version", text[TextKey.Version]);
}
@@ -58,6 +58,19 @@ namespace SafeExamBrowser.Core.UnitTests.I18n
Assert.IsTrue(text.Count == 0);
}
+ [TestMethod]
+ public void MustNeverSetNullValue()
+ {
+ var location = Assembly.GetAssembly(typeof(XmlTextResourceTests)).Location;
+ var path = Path.GetDirectoryName(location) + $@"\{nameof(I18n)}\Text_Valid.xml";
+ var sut = new XmlTextResource(path);
+
+ var text = sut.LoadText();
+
+ Assert.IsNotNull(text);
+ Assert.AreEqual(string.Empty, text[TextKey.Notification_LogTooltip]);
+ }
+
[TestMethod]
[ExpectedException(typeof(ArgumentException))]
public void MustNotAcceptInvalidPath()
@@ -71,5 +84,18 @@ namespace SafeExamBrowser.Core.UnitTests.I18n
{
new XmlTextResource(null);
}
+
+ [TestMethod]
+ public void MustTrimValues()
+ {
+ var location = Assembly.GetAssembly(typeof(XmlTextResourceTests)).Location;
+ var path = Path.GetDirectoryName(location) + $@"\{nameof(I18n)}\Text_Valid.xml";
+ var sut = new XmlTextResource(path);
+
+ var text = sut.LoadText();
+
+ Assert.IsNotNull(text);
+ Assert.AreEqual("Hello world", text[TextKey.Notification_AboutTooltip]);
+ }
}
}
diff --git a/SafeExamBrowser.Core/I18n/Text.xml b/SafeExamBrowser.Core/I18n/Text.xml
index 01d3d549..e242e96c 100644
--- a/SafeExamBrowser.Core/I18n/Text.xml
+++ b/SafeExamBrowser.Core/I18n/Text.xml
@@ -1,45 +1,129 @@
- Open Console
- Application Log
- The client configuration has been saved and will be used when you start the application the next time. Do you want to quit for now?
- Configuration Successful
- An unexpected error occurred during the shutdown procedure! Please consult the application log for more information...
- Shutdown Error
- An unexpected error occurred during the startup procedure! Please consult the application log for more information...
- Startup Error
- About Safe Exam Browser
- Application Log
- Emptying clipboard
- Initializing browser
- Initializing application configuration
- Initializing process monitoring
- Initializing taskbar
- Initializing window monitoring
- Initializing working area
- Restoring working area
- Initiating shutdown procedure
- Starting event handling
- Starting keyboard interception
- Starting mouse interception
- Initiating startup procedure
- Stopping event handling
- Stopping keyboard interception
- Stopping mouse interception
- Stopping process monitoring
- Stopping window monitoring
- Terminating browser
- Terminating taskbar
- Waiting for Windows explorer to start up
- Waiting for Windows explorer to shut down
- Plugged in, charging... (%%CHARGE%%%)
- Fully charged (%%CHARGE%%%)
- The battery charge is critically low. Please connect your computer to a power supply!
- The battery charge is getting low. Consider connecting your computer to a power supply in time...
- %%HOURS%%h %%MINUTES%%min remaining (%%CHARGE%%%)
- Click to choose a different keyboard layout...
- Connected to '%%NAME%%'
- Disconnected
- No wireless network adapter available or turned on
- Version
+
+ Open Console
+
+
+ Application Log
+
+
+ The client configuration has been saved and will be used when you start the application the next time. Do you want to quit for now?
+
+
+ Configuration Successful
+
+
+ An unexpected error occurred during the shutdown procedure! Please consult the application log for more information...
+
+
+ Shutdown Error
+
+
+ An unexpected error occurred during the startup procedure! Please consult the application log for more information...
+
+
+ Startup Error
+
+
+ About Safe Exam Browser
+
+
+ Application Log
+
+
+ Emptying clipboard
+
+
+ Initializing browser
+
+
+ Initializing application configuration
+
+
+ Initializing process monitoring
+
+
+ Initializing taskbar
+
+
+ Initializing window monitoring
+
+
+ Initializing working area
+
+
+ Restoring working area
+
+
+ Initiating shutdown procedure
+
+
+ Starting event handling
+
+
+ Starting keyboard interception
+
+
+ Starting mouse interception
+
+
+ Initiating startup procedure
+
+
+ Stopping event handling
+
+
+ Stopping keyboard interception
+
+
+ Stopping mouse interception
+
+
+ Stopping process monitoring
+
+
+ Stopping window monitoring
+
+
+ Terminating browser
+
+
+ Terminating taskbar
+
+
+ Waiting for Windows explorer to start up
+
+
+ Waiting for Windows explorer to shut down
+
+
+ Plugged in, charging... (%%CHARGE%%%)
+
+
+ Fully charged (%%CHARGE%%%)
+
+
+ The battery charge is critically low. Please connect your computer to a power supply!
+
+
+ The battery charge is getting low. Consider connecting your computer to a power supply in time...
+
+
+ %%HOURS%%h %%MINUTES%%min remaining (%%CHARGE%%%)
+
+
+ Click to choose a different keyboard layout...
+
+
+ Connected to '%%NAME%%'
+
+
+ Disconnected
+
+
+ No wireless network adapter available or turned on
+
+
+ Version
+
\ No newline at end of file
diff --git a/SafeExamBrowser.Core/I18n/XmlTextResource.cs b/SafeExamBrowser.Core/I18n/XmlTextResource.cs
index fd8c8b17..3586e2d5 100644
--- a/SafeExamBrowser.Core/I18n/XmlTextResource.cs
+++ b/SafeExamBrowser.Core/I18n/XmlTextResource.cs
@@ -45,9 +45,12 @@ namespace SafeExamBrowser.Core.I18n
foreach (var definition in xml.Root.Descendants())
{
- if (Enum.TryParse(definition.Name.LocalName, out TextKey key))
+ var isEntry = definition.Name.LocalName == "Entry";
+ var hasValidKey = Enum.TryParse(definition.Attribute("key")?.Value, out TextKey key);
+
+ if (isEntry && hasValidKey)
{
- text[key] = definition.Value;
+ text[key] = definition.Value?.Trim() ?? string.Empty;
}
}