diff --git a/BackupEssentials/App.xaml.cs b/BackupEssentials/App.xaml.cs index dca6418..f0e741e 100644 --- a/BackupEssentials/App.xaml.cs +++ b/BackupEssentials/App.xaml.cs @@ -55,7 +55,7 @@ namespace BackupEssentials{ if (parser.HasFlag("nohide"))window.WindowState = WindowState.Normal; window.Show(); } - else throw new ArgumentException("Backup could not begin, destination is empty. Program arguments: "+string.Join(" ",args.Args)); + else throw new ArgumentException(Sys.Settings.Default.Language["General.App.DestinationMissing",string.Join(" ",args.Args)]); } else if (parser.HasFlag("runcompat")){ MainWindow window = new MainWindow(); diff --git a/BackupEssentials/Backup/BackupLocation.cs b/BackupEssentials/Backup/BackupLocation.cs index 654828e..ffee622 100644 --- a/BackupEssentials/Backup/BackupLocation.cs +++ b/BackupEssentials/Backup/BackupLocation.cs @@ -1,4 +1,5 @@ -using BackupEssentials.Utils; +using BackupEssentials.Sys; +using BackupEssentials.Utils; using System; using System.Collections.Generic; using System.IO; @@ -57,8 +58,8 @@ namespace BackupEssentials.Backup{ } void StringDictionarySerializer.IObjectToDictionary.FromDictionary(SafeDictionary<string,string> dict){ - Name = dict["Name"] ?? "<unknown>"; - Directory = dict["Dir"] ?? "<unknown>"; + Name = dict["Name"] ?? Settings.Default.Language["Backup.Location.UnknownName"]; + Directory = dict["Dir"] ?? Settings.Default.Language["Backup.Location.UnknownDirectory"]; } public enum DirectoryStatus{ diff --git a/BackupEssentials/Backup/BackupRunner.cs b/BackupEssentials/Backup/BackupRunner.cs index ee015b7..6813337 100644 --- a/BackupEssentials/Backup/BackupRunner.cs +++ b/BackupEssentials/Backup/BackupRunner.cs @@ -69,11 +69,11 @@ namespace BackupEssentials.Backup{ // Verify source files if (srcParent == null){ - throw new Exception("Cannot backup multiple locations!"); + throw new Exception(Settings.Default.Language["BackupWindow.Error.MultipleLocations"]); } for(int a = 1; a < src.Length; a++){ - if (!Directory.GetParent(src[a]).FullName.Equals(srcParent))throw new Exception("Cannot backup multiple locations!"); + if (!Directory.GetParent(src[a]).FullName.Equals(srcParent))throw new Exception(Settings.Default.Language["BackupWindow.Error.MultipleLocations"]); } if (srcParent[srcParent.Length-1] == '\\')srcParent = srcParent.Substring(0,srcParent.Length-1); diff --git a/BackupEssentials/BackupWindow.xaml b/BackupEssentials/BackupWindow.xaml index 8514991..3e985d8 100644 --- a/BackupEssentials/BackupWindow.xaml +++ b/BackupEssentials/BackupWindow.xaml @@ -4,6 +4,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:sys="clr-namespace:System;assembly=mscorlib" + xmlns:system="clr-namespace:BackupEssentials.Sys" xmlns:custom="clr-namespace:BackupEssentials.Controls" xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" mc:Ignorable="d" x:Class="BackupEssentials.BackupWindow" @@ -21,12 +22,12 @@ <RowDefinition Height="*"/> </Grid.RowDefinitions> - <Label x:Name="LabelInfo" Content="Preparing backup..." HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="#FFDDDDDD" FontSize="18"/> + <Label x:Name="LabelInfo" Content="" HorizontalAlignment="Left" VerticalAlignment="Center" Foreground="#FFDDDDDD" FontSize="18"/> <ProgressBar x:Name="ProgressBar" Margin="8,0" Grid.Row="1"/> - <WrapPanel Grid.Row="2" Orientation="Horizontal" Margin="8,12,8,0" HorizontalAlignment="Right"> - <Button x:Name="ButtonShowReport" Template="{StaticResource ButtonStyleDefault}" Content="Show report" IsEnabled="False" Margin="0,0,8,0" FontSize="16" Click="ButtonShowReportClick" Width="115"/> - <Button x:Name="ButtonEnd" Template="{StaticResource ButtonStyleRedDefault}" Content="Cancel" FontSize="16" Click="ButtonEndClick" Width="85"/> + <WrapPanel Grid.Row="2" Orientation="Horizontal" Margin="8,12,8,0" HorizontalAlignment="Right" DataContext="{Binding Source={x:Static system:Settings.Default}}"> + <Button x:Name="ButtonShowReport" Template="{StaticResource ButtonStyleDefault}" Content="{Binding Language[BackupWindow.Button.ShowReport]}" IsEnabled="False" Margin="0,0,8,0" FontSize="16" Click="ButtonShowReportClick"/> + <Button x:Name="ButtonEnd" Template="{StaticResource ButtonStyleRedDefault}" Content="{Binding Language[BackupWindow.Button.Cancel]}" FontSize="16" Click="ButtonEndClick"/> </WrapPanel> </Grid> </DockPanel> diff --git a/BackupEssentials/BackupWindow.xaml.cs b/BackupEssentials/BackupWindow.xaml.cs index 88f23b1..42b5756 100644 --- a/BackupEssentials/BackupWindow.xaml.cs +++ b/BackupEssentials/BackupWindow.xaml.cs @@ -4,6 +4,7 @@ using BackupEssentials.Sys; using System; using System.ComponentModel; using System.Diagnostics; +using System.Globalization; using System.Windows; using System.Windows.Shell; using System.Windows.Threading; @@ -22,7 +23,7 @@ namespace BackupEssentials{ TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate; ProgressBar.IsIndeterminate = true; - LabelInfo.Content = "Preparing backup..."; + LabelInfo.Content = Settings.Default.Language["BackupWindow.Run.Preparing"]; runner.EventProgressUpdate = WorkerProgressUpdate; runner.EventCompleted = WorkerCompleted; @@ -39,7 +40,7 @@ namespace BackupEssentials{ Closing += (sender, args) => { if (HistoryGenWorker != null){ - if (MessageBox.Show(App.Window,"The history entry has not been generated yet, do you want to close the window anyways?","History entry is generating",MessageBoxButton.YesNo,MessageBoxImage.Warning) == MessageBoxResult.No){ + if (MessageBox.Show(App.Window,Settings.Default.Language["BackupWindow.HistoryGenWarning"],Settings.Default.Language["BackupWindow.HistoryGenWarning.Title"],MessageBoxButton.YesNo,MessageBoxImage.Warning) != MessageBoxResult.Yes){ args.Cancel = true; } } @@ -56,7 +57,7 @@ namespace BackupEssentials{ ProgressBar.Value = e.ProgressPercentage; } - LabelInfo.Content = "Processing the files and folders..."; + LabelInfo.Content = Settings.Default.Language["BackupWindow.Run.Processing"]; if (e.ProgressPercentage == 0 && e.UserState is int){ ActionCount = (int)e.UserState; @@ -66,7 +67,7 @@ namespace BackupEssentials{ private void WorkerCompleted(object sender, RunWorkerCompletedEventArgs e){ ButtonShowReport.IsEnabled = true; - ButtonEnd.Content = "Close"; + ButtonEnd.Content = Settings.Default.Language["BackupWindow.Button.Close"]; Report = e.Result as BackupReport; Settings settings = Settings.Default; @@ -76,7 +77,7 @@ namespace BackupEssentials{ HistoryGenWorker = null; if (historyArgs.Result == null){ - App.LogException(historyArgs.Error == null ? new Exception("History generation failed (no stack trace)") : new Exception("History generation failed",historyArgs.Error)); + App.LogException(historyArgs.Error == null ? new Exception(Settings.Default.Language["BackupWindow.Error.HistoryGenFailedNoTrace"]) : new Exception(Settings.Default.Language["History generation failed"],historyArgs.Error)); } }); } @@ -94,7 +95,7 @@ namespace BackupEssentials{ ProgressBar.Value = 100; ProgressBar.Value = 99; // progress bar animation hack ProgressBar.Value = 100; - LabelInfo.Content = "Finished! Updated "+ActionCount+" files and folders."; + LabelInfo.Content = Settings.Default.Language["BackupWindow.Run.Finished.",ActionCount,ActionCount.ToString(CultureInfo.InvariantCulture)]; int closeTime = Settings.Default.WindowCloseTime.Value; if (closeTime == -1)return; diff --git a/BackupEssentials/Data/DataStorage.cs b/BackupEssentials/Data/DataStorage.cs index cafff9c..8b5bca5 100644 --- a/BackupEssentials/Data/DataStorage.cs +++ b/BackupEssentials/Data/DataStorage.cs @@ -1,4 +1,5 @@ using BackupEssentials.Backup.History; +using BackupEssentials.Sys; using BackupEssentials.Utils; using System; using System.Collections.Generic; @@ -86,8 +87,8 @@ namespace BackupEssentials.Backup.Data{ } public static void Save(bool force){ - if (!IsSetupForSaving)throw new NotSupportedException("DataStorage was not initialized for saving!"); - else if (SaveTimer == null && !force)throw new NotSupportedException("DataStorage was not initialized for scheduled saving!"); + if (!IsSetupForSaving)throw new NotSupportedException(Settings.Default.Language["General.Storage.ErrorSaving"]); + else if (SaveTimer == null && !force)throw new NotSupportedException(Settings.Default.Language["General.Storage.ErrorScheduledSaving"]); if (!force){ SaveTimer.NeedsUpdate = true; diff --git a/BackupEssentials/Pages/About.xaml.cs b/BackupEssentials/Pages/About.xaml.cs index 9fcc7d1..973aced 100644 --- a/BackupEssentials/Pages/About.xaml.cs +++ b/BackupEssentials/Pages/About.xaml.cs @@ -16,10 +16,12 @@ namespace BackupEssentials.Pages{ StringBuilder build = new StringBuilder(); OperatingSystem os = Environment.OSVersion; - build.Append("You are using ").Append(WindowsVersion.Get()).Append(' '); - build.Append(Environment.Is64BitOperatingSystem ? "x64" : "x86").Append(' '); - build.Append(os.ServicePack.Replace("Service Pack ","SP")).Append(' '); - build.Append(WindowsVersion.IsFullySupported() ? "(supported)." : "(not supported)."); + build.Append(WindowsVersion.Get()).Append(' ').Append(Environment.Is64BitOperatingSystem ? "x64" : "x86").Append(' ').Append(os.ServicePack.Replace("Service Pack ","SP")); + string version = build.ToString(); + + build.Clear(); + build.Append(Sys.Settings.Default.Language["About.WinVersion.Using",version]).Append(' '); + build.Append(Sys.Settings.Default.Language[WindowsVersion.IsFullySupported() ? "About.WinVersion.Supported" : "About.WinVersion.Unsupported"]); AboutTextOS.Text = build.ToString(); } diff --git a/BackupEssentials/Resources/Lang/en b/BackupEssentials/Resources/Lang/en index f2510c4..8512eab 100644 --- a/BackupEssentials/Resources/Lang/en +++ b/BackupEssentials/Resources/Lang/en @@ -5,6 +5,10 @@ General.App.AlreadyRunning = The application is already running, but is not resp General.App.AlreadyRunning.Title = Application is already running General.App.CannotClose = Could not close the application: $0 General.App.CannotClose.Title = Error closing application +General.App.DestinationMissing = Backup could not begin, destination is empty. Program arguments: $0 + +General.Storage.ErrorSaving = DataStorage was not initialized for saving! +General.Storage.ErrorScheduledSaving = DataStorage was not initialized for scheduled saving! General.UI.MenuButton.Home = Home General.UI.MenuButton.Backup = Backup @@ -21,6 +25,9 @@ Backup.Button.Add = Add location Backup.Button.Edit = Edit Backup.Button.Remove = Remove +Backup.Location.UnknownName = (unknown) +Backup.Location.UnknownDirectory = (unknown) + BackupEdit.Label.Name = Name: BackupEdit.Label.Directory = Directory: BackupEdit.Label.AdvancedSettings = Show advanced settings @@ -118,10 +125,15 @@ Settings.Option.DateFormat.Detect = Detect ($0) # PAGE - ABOUT # #==============# About.Version = Version -About.Version.Unknown = <unknown> +About.Version.Unknown = (unknown) About.Author = Designed and programmed by chylex. About.License = Product license information +About.WinVersion.Using = You are using $0 +About.WinVersion.Supported = (supported). +About.WinVersion.Unsupported (not supported). +About.WinVersion.Unknown = (unknown) + About.Support = Support: About.Support.Link = Issues on GitHub About.OfficialWebsite = Visit the official website: @@ -131,7 +143,21 @@ About.Twitter = Follow me on Twitter: #=================# # BACKUP - WINDOW # #=================# +BackupWindow.Button.ShowReport = Show report +BackupWindow.Button.Cancel = Cancel +BackupWindow.Button.Close = Close +BackupWindow.Run.Preparing = Preparing backup... +BackupWindow.Run.Processing = Processing the files and folders... +BackupWindow.Run.Finished.* = Finished! Updated $0 files and folder. +BackupWindow.Run.Finished.1 = Finished! Updated 1 file or folder. + +BackupWindow.Error.MultipleLocations = Cannot backup multiple locations in different folders! +BackupWindow.Error.HistoryGenFailed = History generation failed +BackupWindow.Error.HistoryGenFailedNoTrace = History generation failed (unknown error) + +BackupWindow.HistoryGenWarning.Title = History entry is generating +BackupWindow.HistoryGenWarning = The history entry has not been generated yet, do you want to close the window anyways? #==================# # BACKUP - REPORTS # diff --git a/BackupEssentials/Utils/WindowsVersion.cs b/BackupEssentials/Utils/WindowsVersion.cs index b395bcf..e081e2d 100644 --- a/BackupEssentials/Utils/WindowsVersion.cs +++ b/BackupEssentials/Utils/WindowsVersion.cs @@ -1,4 +1,5 @@ -using Microsoft.Win32; +using BackupEssentials.Sys; +using Microsoft.Win32; using System; namespace BackupEssentials.Utils{ @@ -13,7 +14,7 @@ namespace BackupEssentials.Utils{ if (key != null)return CachedVersionName = (string)key.GetValue("ProductName"); }catch{} - return CachedVersionName = (GetFromEnvironment() ?? "(unknown)"); + return CachedVersionName = (GetFromEnvironment() ?? Settings.Default.Language["About.WinVersion.Unknown"]); } private static string GetFromEnvironment(){