Skip to content

Commit

Permalink
Added missing localized text
Browse files Browse the repository at this point in the history
  • Loading branch information
Timthreetwelve committed Apr 3, 2024
1 parent cac571a commit dfdba65
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 36 deletions.
67 changes: 32 additions & 35 deletions WUView/Helpers/TextFileViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,53 @@ public static class TextFileViewer
/// <summary>
/// Opens specified text file
/// </summary>
/// <param name="txtfile">Full path for text file</param>
/// <param name="textFile">Full path for text file</param>
///
public static void ViewTextFile(string txtfile)
public static void ViewTextFile(string textFile)
{
if (File.Exists(txtfile))
try
{
try
using Process p = new();
p.StartInfo.FileName = textFile;
p.StartInfo.UseShellExecute = true;
p.StartInfo.ErrorDialog = false;
_ = p.Start();
}
catch (Win32Exception ex)
{
if (ex.NativeErrorCode == 1155)
{
using Process p = new();
p.StartInfo.FileName = txtfile;
p.StartInfo.FileName = "notepad.exe";
p.StartInfo.Arguments = textFile;
p.StartInfo.UseShellExecute = true;
p.StartInfo.ErrorDialog = false;
_ = p.Start();
_log.Debug($"Opening {textFile} in Notepad.exe");
}
catch (Win32Exception ex)
{
if (ex.NativeErrorCode == 1155)
{
using Process p = new();
p.StartInfo.FileName = "notepad.exe";
p.StartInfo.Arguments = txtfile;
p.StartInfo.UseShellExecute = true;
p.StartInfo.ErrorDialog = false;
_ = p.Start();
_log.Debug($"Opening {txtfile} in Notepad.exe");
}
else
{
#if messagebox
_ = MessageBox.Show($"Error reading file {txtfile}\n{ex.Message}", "Watcher Error",
MessageBoxButton.OK, MessageBoxImage.Error);
#endif
_log.Error($"* Unable to open {txtfile}");
_log.Error($"* {ex.Message}");
}
}
catch (Exception ex)
else
{
#if messagebox
_ = MessageBox.Show("Unable to start default application used to open" +
$" {txtfile}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
string msg = string.Format(GetStringResource("MsgText_ErrorReadingFile"), textFile);
_ = MessageBox.Show($"{msg}\n{ex.Message}",
GetStringResource("MsgText_ErrorCaption"),
MessageBoxButton.OK,
MessageBoxImage.Error);
#endif
_log.Error($"* Unable to open {txtfile}");
_log.Error($"* {ex.Message}");
_log.Error(ex, $"Unable to open {textFile}");
}
}
else
catch (Exception ex)
{
_log.Error($">>> File not found: {txtfile}");
#if messagebox
string msg = string.Format(GetStringResource("MsgText_ErrorOpeningFile"), textFile);
_ = MessageBox.Show($"{msg}\n{ex.Message}",
GetStringResource("MsgText_ErrorCaption"),
MessageBoxButton.OK,
MessageBoxImage.Error);
#endif
_log.Error(ex, $"Unable to open {textFile}");
}
}
#endregion
#endregion Text file viewer
}
10 changes: 9 additions & 1 deletion WUView/Languages/Strings.en-US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
<sys:String x:Key="MsgText_ApplicationStarting">is starting up</sys:String>
<sys:String x:Key="MsgText_AppUpdateCheckFailed">Check for update failed. See the log for more information.</sys:String>
<sys:String x:Key="MsgText_AppUpdateChecking">Checking for update.</sys:String>
<sys:String x:Key="MsgText_AppUpdateGoToRelease">Do you want to go to the release page?</sys:String>
<sys:String x:Key="MsgText_AppUpdateCloseGetMyIP">Clicking 'Yes' will close Get My IP.</sys:String>
<sys:String x:Key="MsgText_AppUpdateGoToRelease">Do you want to go to the release page?</sys:String>
<sys:String x:Key="MsgText_AppUpdateNewerFound">A newer release ({0}) has been found.</sys:String>
<sys:String x:Key="MsgText_AppUpdateNoneFound">No newer releases were found.</sys:String>
<sys:String x:Key="MsgText_ColumnSortCleared">Column sort cleared</sys:String>
Expand All @@ -111,6 +111,9 @@
<sys:String x:Key="MsgText_DisplayedUpdates">Displaying {0} of {1} updates</sys:String>
<sys:String x:Key="MsgText_ElapsedTime">Elapsed time</sys:String>
<sys:String x:Key="MsgText_Error_TestLanguage">There is a problem with the language file.</sys:String>
<sys:String x:Key="MsgText_ErrorCaption">ERROR</sys:String>
<sys:String x:Key="MsgText_ErrorOpeningFile">Error opening {0}</sys:String>
<sys:String x:Key="MsgText_ErrorReadingFile">Error reading {0}</sys:String>
<sys:String x:Key="MsgText_EventLogNA">No Event Logs records were found for this update.</sys:String>
<sys:String x:Key="MsgText_EventLogNoRecords">No Event Log records containing "{0}" were found.</sys:String>
<sys:String x:Key="MsgText_ExcludingContaining">Excluding updates containing:</sys:String>
Expand Down Expand Up @@ -270,4 +273,9 @@
<!-- A | MsgText_AppUpdateCloseGetMyIP -->
<!-- End of changes on 2023/11/28 @ 02:00 UTC -->

<!-- Begin changes on 2024/04/03 @ 18:00 UTC -->
<!-- A | MsgText_ErrorCaption -->
<!-- A | MsgText_ErrorOpeningFile -->
<!-- A | MsgText_ErrorReadingFile -->
<!-- End of changes on 2024/04/03 @ 18:00 UTC -->
</ResourceDictionary>

0 comments on commit dfdba65

Please sign in to comment.