diff --git a/src/UniGetUI.Core.LanguageEngine/Assets/Data/LanguagesReference.json b/src/UniGetUI.Core.LanguageEngine/Assets/Data/LanguagesReference.json index bb4d68654..9999f6c8e 100644 --- a/src/UniGetUI.Core.LanguageEngine/Assets/Data/LanguagesReference.json +++ b/src/UniGetUI.Core.LanguageEngine/Assets/Data/LanguagesReference.json @@ -30,6 +30,7 @@ "pt_PT": "Portuguese (Portugal)", "ro": "Romanian - Română", "ru": "Russian - Русский", + "sk": "Slovak - Slovenčina", "sr": "Serbian - Srpski", "sq": "Albanian - Shqip", "si": "Sinhala - සිංහල", diff --git a/src/UniGetUI.Core.LanguageEngine/LanguageEngine.cs b/src/UniGetUI.Core.LanguageEngine/LanguageEngine.cs index bccf0a302..e7a514577 100644 --- a/src/UniGetUI.Core.LanguageEngine/LanguageEngine.cs +++ b/src/UniGetUI.Core.LanguageEngine/LanguageEngine.cs @@ -88,11 +88,11 @@ public Dictionary LoadLanguageFile(string LangKey, bool ForceBun /// The Id of the language to download /// Use the new or the old Url (should not be used manually) /// - public async Task DownloadUpdatedLanguageFile(string LangKey, bool UseOldUrl = false) + public async Task DownloadUpdatedLanguageFile(string LangKey) { try { - Uri NewFile = new("https://raw.githubusercontent.com/marticliment/WingetUI/main/src/" + (UseOldUrl ? "wingetui" : "UniGetUI") + "/Assets/Languages/lang_" + LangKey + ".json"); + Uri NewFile = new("https://raw.githubusercontent.com/marticliment/WingetUI/main/src/UniGetUI.Core.LanguageEngine/Assets/Languages/lang_" + LangKey + ".json"); HttpClient client = new(); string fileContents = await client.GetStringAsync(NewFile); @@ -106,13 +106,8 @@ public async Task DownloadUpdatedLanguageFile(string LangKey, bool UseOldUrl = f } catch (Exception e) { - if (e is HttpRequestException && !UseOldUrl) - await DownloadUpdatedLanguageFile(LangKey, true); - else - { - Logger.Warn("Could not download updated translations from GitHub"); - Logger.Warn(e); - } + Logger.Warn("Could not download updated translations from GitHub"); + Logger.Warn(e); } } diff --git a/src/UniGetUI.Core.Tools/Tools.cs b/src/UniGetUI.Core.Tools/Tools.cs index 39698f76a..0005aa672 100644 --- a/src/UniGetUI.Core.Tools/Tools.cs +++ b/src/UniGetUI.Core.Tools/Tools.cs @@ -6,6 +6,7 @@ using UniGetUI.Core.Data; using UniGetUI.Core.Language; using UniGetUI.Core.Logging; +using Jeffijoe.MessageFormat; namespace UniGetUI.Core.Tools { @@ -24,12 +25,26 @@ public static class CoreTools /// /// The string to translate /// The translated string if available, the original string otherwise - public static string Translate(string text) - { + public static string Translate(string text) { if(LanguageEngine == null) LanguageEngine = new LanguageEngine(); return LanguageEngine.Translate(text); } + public static string Translate(string text, Dictionary dict) + { + return MessageFormatter.Format(Translate(text), dict); + } + + public static string Translate(string text, params object[] values) + { + var dict = new Dictionary(); + foreach (var (item, index) in values.Select((item, index) => (item, index))) + { + dict.Add(index.ToString(), item); + } + return MessageFormatter.Format(Translate(text), dict); + } + public static void ReloadLanguageEngineInstance(string ForceLanguage = "") { LanguageEngine = new LanguageEngine(ForceLanguage); diff --git a/src/UniGetUI.Core.Tools/UniGetUI.Core.Tools.csproj b/src/UniGetUI.Core.Tools/UniGetUI.Core.Tools.csproj index d07f72acd..2d0272625 100644 --- a/src/UniGetUI.Core.Tools/UniGetUI.Core.Tools.csproj +++ b/src/UniGetUI.Core.Tools/UniGetUI.Core.Tools.csproj @@ -25,6 +25,10 @@ enable + + + + diff --git a/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGet.cs b/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGet.cs index 77bc603c4..31ceec598 100644 --- a/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGet.cs +++ b/src/UniGetUI.PackageEngine.Managers.Generic.NuGet/BaseNuGet.cs @@ -96,7 +96,7 @@ protected sealed override async Task FindPackages_UnSafe(string query if (AlreadyProcessedPackages.ContainsKey(id) && AlreadyProcessedPackages[id].version_float >= float_version) continue; - AlreadyProcessedPackages[id] = new SearchResult() { id = id, version = version, version_float = float_version }; + AlreadyProcessedPackages[id] = new SearchResult { id = id, version = version, version_float = float_version }; } foreach(var package in AlreadyProcessedPackages.Values) Packages.Add(new Package(CoreTools.FormatAsName(package.id), package.id, package.version, source, this)); diff --git a/src/UniGetUI/App.xaml.cs b/src/UniGetUI/App.xaml.cs index 96409df8f..06ec429b2 100644 --- a/src/UniGetUI/App.xaml.cs +++ b/src/UniGetUI/App.xaml.cs @@ -390,7 +390,7 @@ private async void UpdateUniGetUIIfPossible(int round = 0) Logger.Info("Latest version : " + LatestVersion.ToString(CultureInfo.InvariantCulture)); banner = MainWindow.UpdatesBanner; - banner.Title = CoreTools.Translate("WingetUI version {0} is being downloaded.").Replace("{0}", LatestVersion.ToString(CultureInfo.InvariantCulture)); + banner.Title = CoreTools.Translate("WingetUI version {0} is being downloaded.", LatestVersion.ToString(CultureInfo.InvariantCulture)); banner.Message = CoreTools.Translate("This may take a minute or two"); banner.Severity = InfoBarSeverity.Informational; banner.IsOpen = true; @@ -416,7 +416,7 @@ private async void UpdateUniGetUIIfPossible(int round = 0) if (Hash == InstallerHash) { - banner.Title = CoreTools.Translate("WingetUI {0} is ready to be installed.").Replace("{0}", LatestVersion.ToString(CultureInfo.InvariantCulture)); + banner.Title = CoreTools.Translate("WingetUI {0} is ready to be installed.", LatestVersion.ToString(CultureInfo.InvariantCulture)); banner.Message = CoreTools.Translate("The update will be installed upon closing WingetUI"); banner.ActionButton = new Button(); banner.ActionButton.Content = CoreTools.Translate("Update now"); diff --git a/src/UniGetUI/Interface/BackgroundApi.cs b/src/UniGetUI/Interface/BackgroundApi.cs index cfb053de6..1e7887160 100644 --- a/src/UniGetUI/Interface/BackgroundApi.cs +++ b/src/UniGetUI/Interface/BackgroundApi.cs @@ -54,7 +54,7 @@ public async Task Start() NancyHost host; try { - host = new NancyHost(new HostConfiguration() { RewriteLocalhost = false, }, new Uri("http://localhost:7058/")); + host = new NancyHost(new HostConfiguration { RewriteLocalhost = false, }, new Uri("http://localhost:7058/")); host.Start(); } catch diff --git a/src/UniGetUI/Interface/Dialogs/AboutUniGetUI.xaml.cs b/src/UniGetUI/Interface/Dialogs/AboutUniGetUI.xaml.cs index a3ab543af..39e97c4d7 100644 --- a/src/UniGetUI/Interface/Dialogs/AboutUniGetUI.xaml.cs +++ b/src/UniGetUI/Interface/Dialogs/AboutUniGetUI.xaml.cs @@ -56,7 +56,7 @@ private void SelectorBar_SelectionChanged(SelectorBar sender, SelectorBarSelecti SlideNavigationTransitionEffect slideNavigationTransitionEffect = currentSelectedIndex - previousSelectedIndex > 0 ? SlideNavigationTransitionEffect.FromRight : SlideNavigationTransitionEffect.FromLeft; - ContentFrame.Navigate(pageType, null, new SlideNavigationTransitionInfo() { Effect = slideNavigationTransitionEffect }); + ContentFrame.Navigate(pageType, null, new SlideNavigationTransitionInfo { Effect = slideNavigationTransitionEffect }); previousSelectedIndex = currentSelectedIndex; diff --git a/src/UniGetUI/Interface/MainView.xaml.cs b/src/UniGetUI/Interface/MainView.xaml.cs index 8c48f3302..0a87899c0 100644 --- a/src/UniGetUI/Interface/MainView.xaml.cs +++ b/src/UniGetUI/Interface/MainView.xaml.cs @@ -148,8 +148,8 @@ private void MoreNavButton_Click(object sender, NavButton.NavButtonEventArgs e) button.ToggleButton.IsChecked = false; MoreNavButton.ToggleButton.IsChecked = true; - (VersionMenuItem as MenuFlyoutItem).Text = CoreTools.Translate("WingetUI Version {0}").Replace("{0}", CoreData.VersionName); - MoreNavButtonMenu.ShowAt(MoreNavButton, new FlyoutShowOptions() { ShowMode = FlyoutShowMode.Standard }); + (VersionMenuItem as MenuFlyoutItem).Text = CoreTools.Translate("WingetUI Version {0}", CoreData.VersionName); + MoreNavButtonMenu.ShowAt(MoreNavButton, new FlyoutShowOptions { ShowMode = FlyoutShowMode.Standard }); MoreNavButtonMenu.Closed += (s, e) => { @@ -246,7 +246,7 @@ public async Task ShowInstallationSettingsForPackageAndContinue(Package pa OptionsDialog.SecondaryButtonText = ""; OptionsDialog.PrimaryButtonText = CoreTools.Translate("Save and close"); OptionsDialog.DefaultButton = ContentDialogButton.Secondary; - OptionsDialog.Title = CoreTools.Translate("{0} installation options").Replace("{0}", package.Name); + OptionsDialog.Title = CoreTools.Translate("{0} installation options", package.Name); OptionsDialog.Content = OptionsPage; OptionsPage.Close += (s, e) => { OptionsDialog.Hide(); }; @@ -272,7 +272,7 @@ public async Task UpdateInstallationSettings(Package packag OptionsDialog.SecondaryButtonText = ""; OptionsDialog.PrimaryButtonText = CoreTools.Translate("Save and close"); OptionsDialog.DefaultButton = ContentDialogButton.Secondary; - OptionsDialog.Title = CoreTools.Translate("{0} installation options").Replace("{0}", package.Name); + OptionsDialog.Title = CoreTools.Translate("{0} installation options", package.Name); OptionsDialog.Content = OptionsPage; OptionsPage.Close += (s, e) => { OptionsDialog.Hide(); }; diff --git a/src/UniGetUI/Interface/MainWindow.xaml.cs b/src/UniGetUI/Interface/MainWindow.xaml.cs index 587105ed4..3b35907f1 100644 --- a/src/UniGetUI/Interface/MainWindow.xaml.cs +++ b/src/UniGetUI/Interface/MainWindow.xaml.cs @@ -74,7 +74,7 @@ public MainWindow() LoadingSthDalog = new ContentDialog(); LoadingSthDalog.Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style; LoadingSthDalog.Title = CoreTools.Translate("Please wait"); - LoadingSthDalog.Content = new ProgressBar() { IsIndeterminate = true, Width = 300 }; + LoadingSthDalog.Content = new ProgressBar { IsIndeterminate = true, Width = 300 }; } #pragma warning restore CS8618 public void HandleNotificationActivation(ToastArguments args, ValueSet input) @@ -199,20 +199,20 @@ private void LoadTrayMenu() DiscoverPackages.ExecuteRequested += (s, e) => { NavigationPage.DiscoverNavButton.ForceClick(); Activate(); }; AvailableUpdates.ExecuteRequested += (s, e) => { NavigationPage.UpdatesNavButton.ForceClick(); Activate(); }; InstalledPackages.ExecuteRequested += (s, e) => { NavigationPage.InstalledNavButton.ForceClick(); Activate(); }; - AboutUniGetUI.Label = CoreTools.Translate("WingetUI Version {0}").Replace("{0}", CoreData.VersionName); + AboutUniGetUI.Label = CoreTools.Translate("WingetUI Version {0}", CoreData.VersionName); ShowUniGetUI.ExecuteRequested += (s, e) => { Activate(); }; QuitUniGetUI.ExecuteRequested += (s, e) => { MainApp.Instance.DisposeAndQuit(); }; - TrayMenu.Items.Add(new MenuFlyoutItem() { Command = DiscoverPackages }); - TrayMenu.Items.Add(new MenuFlyoutItem() { Command = AvailableUpdates }); - TrayMenu.Items.Add(new MenuFlyoutItem() { Command = InstalledPackages }); + TrayMenu.Items.Add(new MenuFlyoutItem { Command = DiscoverPackages }); + TrayMenu.Items.Add(new MenuFlyoutItem { Command = AvailableUpdates }); + TrayMenu.Items.Add(new MenuFlyoutItem { Command = InstalledPackages }); TrayMenu.Items.Add(new MenuFlyoutSeparator()); MenuFlyoutItem _about = new() { Command = AboutUniGetUI }; _about.IsEnabled = false; TrayMenu.Items.Add(_about); TrayMenu.Items.Add(new MenuFlyoutSeparator()); - TrayMenu.Items.Add(new MenuFlyoutItem() { Command = ShowUniGetUI }); - TrayMenu.Items.Add(new MenuFlyoutItem() { Command = QuitUniGetUI }); + TrayMenu.Items.Add(new MenuFlyoutItem { Command = ShowUniGetUI }); + TrayMenu.Items.Add(new MenuFlyoutItem { Command = QuitUniGetUI }); TrayMenu.AreOpenCloseAnimationsEnabled = false; @@ -261,7 +261,7 @@ public void UpdateSystemTrayStatus() if (MainApp.Instance.TooltipStatus.AvailableUpdates == 1) tooltip = CoreTools.Translate("1 update is available") + " - " + Title; else - tooltip = CoreTools.Translate("{0} updates are available").Replace("{0}", MainApp.Instance.TooltipStatus.AvailableUpdates.ToString()) + " - " + Title; + tooltip = CoreTools.Translate("{0} updates are available", MainApp.Instance.TooltipStatus.AvailableUpdates) + " - " + Title; } if(TrayIcon == null) { @@ -289,7 +289,7 @@ public void UpdateSystemTrayStatus() string FullIconPath = Path.Join(CoreData.UniGetUIExecutableDirectory, "\\Assets\\Images\\tray" + modifier + ".ico"); - TrayIcon.SetValue(TaskbarIcon.IconSourceProperty, new BitmapImage() { UriSource = new Uri(FullIconPath) }); + TrayIcon.SetValue(TaskbarIcon.IconSourceProperty, new BitmapImage { UriSource = new Uri(FullIconPath) }); } diff --git a/src/UniGetUI/Interface/Pages/AboutPages/AboutUniGetUI.xaml.cs b/src/UniGetUI/Interface/Pages/AboutPages/AboutUniGetUI.xaml.cs index e69ef541c..4cc9212a9 100644 --- a/src/UniGetUI/Interface/Pages/AboutPages/AboutUniGetUI.xaml.cs +++ b/src/UniGetUI/Interface/Pages/AboutPages/AboutUniGetUI.xaml.cs @@ -18,7 +18,7 @@ public sealed partial class AboutUniGetUI : Page public AboutUniGetUI() { InitializeComponent(); - VersionText.Text = CoreTools.Translate("You have installed WingetUI Version {0}").Replace("{0}", CoreData.VersionName); + VersionText.Text = CoreTools.Translate("You have installed WingetUI Version {0}", CoreData.VersionName); } } diff --git a/src/UniGetUI/Interface/Pages/AboutPages/ThirdPartyLicenses.xaml.cs b/src/UniGetUI/Interface/Pages/AboutPages/ThirdPartyLicenses.xaml.cs index 503b9a262..2983fe220 100644 --- a/src/UniGetUI/Interface/Pages/AboutPages/ThirdPartyLicenses.xaml.cs +++ b/src/UniGetUI/Interface/Pages/AboutPages/ThirdPartyLicenses.xaml.cs @@ -38,7 +38,7 @@ public ThirdPartyLicenses() License = LicenseData.LicenseNames[license], LicenseURL = LicenseData.LicenseURLs[license], HomepageUrl = LicenseData.HomepageUrls[license], - HomepageText = CoreTools.Translate("{0} homepage").Replace("{0}", license) + HomepageText = CoreTools.Translate("{0} homepage", license) }); } diff --git a/src/UniGetUI/Interface/Pages/LogPage.xaml.cs b/src/UniGetUI/Interface/Pages/LogPage.xaml.cs index 564b05c08..917c32f0c 100644 --- a/src/UniGetUI/Interface/Pages/LogPage.xaml.cs +++ b/src/UniGetUI/Interface/Pages/LogPage.xaml.cs @@ -62,7 +62,7 @@ public void SetText(string body) { if (line.Replace("\r", "").Replace("\n", "").Trim() == "") continue; - paragraph.Inlines.Add(new Run() { Text = line.Replace("\r", "").Replace("\n", "") }); + paragraph.Inlines.Add(new Run { Text = line.Replace("\r", "").Replace("\n", "") }); paragraph.Inlines.Add(new LineBreak()); } LogTextBox.Blocks.Clear(); @@ -114,22 +114,22 @@ public void LoadLog() switch (log_entry.Severity) { case LogEntry.SeverityLevel.Debug: - color = new SolidColorBrush() { Color = IS_DARK? DARK_GREY: LIGHT_GREY }; + color = new SolidColorBrush { Color = IS_DARK? DARK_GREY: LIGHT_GREY }; break; case LogEntry.SeverityLevel.Info: - color = new SolidColorBrush() { Color = IS_DARK ? DARK_BLUE : LIGHT_BLUE }; + color = new SolidColorBrush { Color = IS_DARK ? DARK_BLUE : LIGHT_BLUE }; break; case LogEntry.SeverityLevel.Success: - color = new SolidColorBrush() { Color = IS_DARK ? DARK_WHITE : LIGHT_WHITE}; + color = new SolidColorBrush { Color = IS_DARK ? DARK_WHITE : LIGHT_WHITE}; break; case LogEntry.SeverityLevel.Warning: - color = new SolidColorBrush() { Color = IS_DARK ? DARK_YELLOW : LIGHT_YELLOW }; + color = new SolidColorBrush { Color = IS_DARK ? DARK_YELLOW : LIGHT_YELLOW }; break; case LogEntry.SeverityLevel.Error: - color = new SolidColorBrush() { Color = IS_DARK ? DARK_RED : LIGHT_RED }; + color = new SolidColorBrush { Color = IS_DARK ? DARK_RED : LIGHT_RED }; break; default: - color = new SolidColorBrush() { Color = IS_DARK ? DARK_GREY : LIGHT_GREY }; + color = new SolidColorBrush { Color = IS_DARK ? DARK_GREY : LIGHT_GREY }; break; } @@ -138,12 +138,12 @@ public void LoadLog() foreach(var line in lines) if (date_length == -1) { - p.Inlines.Add(new Run() { Text = $"[{log_entry.Time}] {line}\n", Foreground = color }); + p.Inlines.Add(new Run { Text = $"[{log_entry.Time}] {line}\n", Foreground = color }); date_length = $"[{log_entry.Time}] ".Length; } else { - p.Inlines.Add(new Run() { Text = new string(' ', date_length) + line + "\n", Foreground = color }); + p.Inlines.Add(new Run { Text = new string(' ', date_length) + line + "\n", Foreground = color }); } ((Run)p.Inlines[^1]).Text = ((Run)p.Inlines[^1]).Text.TrimEnd(); LogTextBox.Blocks.Add(p); diff --git a/src/UniGetUI/Interface/Pages/PackageDetailsPage.xaml.cs b/src/UniGetUI/Interface/Pages/PackageDetailsPage.xaml.cs index 81e108215..f0c9bbe3e 100644 --- a/src/UniGetUI/Interface/Pages/PackageDetailsPage.xaml.cs +++ b/src/UniGetUI/Interface/Pages/PackageDetailsPage.xaml.cs @@ -76,7 +76,7 @@ public PackageDetailsPage(Package package, OperationType futureOperation) IdTextBlock.Text = package.Id; VersionTextBlock.Text = package.Version; if (package.IsUpgradable) - VersionTextBlock.Text += " - " + CoreTools.Translate("Update to {0} available").Replace("{0}", package.NewVersion); + VersionTextBlock.Text += " - " + CoreTools.Translate("Update to {0} available", package.NewVersion); PackageName.Text = package.Name; SourceNameTextBlock.Text = package.SourceAsString; @@ -192,7 +192,7 @@ public async Task LoadInformation() public async void LoadIcon() { - PackageIcon.Source = new BitmapImage() { UriSource = (await Package.GetIconUrl()) }; + PackageIcon.Source = new BitmapImage { UriSource = (await Package.GetIconUrl()) }; } public async void LoadScreenshots() @@ -205,7 +205,7 @@ public async void LoadScreenshots() IconsExtraBanner.Visibility = Visibility.Visible; ScreenshotsCarroussel.Items.Clear(); foreach (Uri image in screenshots) - ScreenshotsCarroussel.Items.Add(new Image() { Source = new BitmapImage(image) }); + ScreenshotsCarroussel.Items.Add(new Image { Source = new BitmapImage(image) }); } __layout_mode = LayoutMode.Unloaded; @@ -295,7 +295,7 @@ public void PackageDetailsPage_SizeChanged(object? sender = null, SizeChangedEve __layout_mode = LayoutMode.Normal; MainGrid.ColumnDefinitions.Clear(); - MainGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); + MainGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); Grid.SetColumn(TitlePanel, 0); Grid.SetColumn(BasicInfoPanel, 0); Grid.SetColumn(ScreenshotsPanel, 0); @@ -304,13 +304,13 @@ public void PackageDetailsPage_SizeChanged(object? sender = null, SizeChangedEve Grid.SetColumn(MoreDataStackPanel, 0); MainGrid.RowDefinitions.Clear(); - MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); - MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); - MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); - MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); - MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); - MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); - MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); + MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); + MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); + MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); + MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); + MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); + MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); + MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); Grid.SetRow(TitlePanel, 0); Grid.SetRow(DescriptionPanel, 1); Grid.SetRow(BasicInfoPanel, 2); @@ -342,16 +342,16 @@ public void PackageDetailsPage_SizeChanged(object? sender = null, SizeChangedEve __layout_mode = LayoutMode.Wide; MainGrid.ColumnDefinitions.Clear(); - MainGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star), MinWidth = 550 }); - MainGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); + MainGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star), MinWidth = 550 }); + MainGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); Grid.SetColumn(LeftPanel, 0); Grid.SetColumn(RightPanel, 1); Grid.SetColumn(TitlePanel, 0); Grid.SetColumnSpan(TitlePanel, 1); MainGrid.RowDefinitions.Clear(); - MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); - MainGrid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) }); + MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); + MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); Grid.SetRow(LeftPanel, 1); Grid.SetRow(RightPanel, 0); Grid.SetRow(TitlePanel, 0); diff --git a/src/UniGetUI/Interface/Pages/SettingsPage.xaml.cs b/src/UniGetUI/Interface/Pages/SettingsPage.xaml.cs index 9fe635d17..ec4a80d9d 100644 --- a/src/UniGetUI/Interface/Pages/SettingsPage.xaml.cs +++ b/src/UniGetUI/Interface/Pages/SettingsPage.xaml.cs @@ -59,16 +59,16 @@ public SettingsInterface() Dictionary updates_dict = new() { - {CoreTools.Translate("{0} minutes").Replace("{0}", "10"), "600"}, - {CoreTools.Translate("{0} minutes").Replace("{0}", "30"), "1800"}, + {CoreTools.Translate("{0} minutes", 10), "600"}, + {CoreTools.Translate("{0} minutes", 30), "1800"}, {CoreTools.Translate("1 hour"), "3600"}, - {CoreTools.Translate("{0} hours").Replace("{0}", "2"), "7200"}, - {CoreTools.Translate("{0} hours").Replace("{0}", "4"), "14400"}, - {CoreTools.Translate("{0} hours").Replace("{0}", "8"), "28800"}, - {CoreTools.Translate("{0} hours").Replace("{0}", "12"), "43200"}, + {CoreTools.Translate("{0} hours", 2), "7200"}, + {CoreTools.Translate("{0} hours", 4), "14400"}, + {CoreTools.Translate("{0} hours", 8), "28800"}, + {CoreTools.Translate("{0} hours", 12), "43200"}, {CoreTools.Translate("1 day"), "86400"}, - {CoreTools.Translate("{0} days").Replace("{0}", "2"), "172800"}, - {CoreTools.Translate("{0} days").Replace("{0}", "3"), "259200"}, + {CoreTools.Translate("{0} days", 2), "172800"}, + {CoreTools.Translate("{0} days", 3), "259200"}, {CoreTools.Translate("1 week"), "604800"} }; @@ -197,12 +197,12 @@ void SetManagerStatus(PackageManager Manager, bool ShowVersion = false) if (Manager.IsEnabled() && Manager.Status.Found) { ManagerStatus.Severity = InfoBarSeverity.Success; - ManagerStatus.Title = CoreTools.Translate("{pm} is enabled and ready to go").Replace("{pm}", Manager.Name); + ManagerStatus.Title = CoreTools.Translate("{pm} is enabled and ready to go", new Dictionary{ { "pm", Manager.Name } }); if (!Manager.Status.Version.Contains("\n")) - ManagerStatus.Message = CoreTools.Translate("{pm} version:").Replace("{pm}", Manager.Name) + " " + Manager.Status.Version; + ManagerStatus.Message = CoreTools.Translate("{pm} version:", new Dictionary{ { "pm", Manager.Name } }) + " " + Manager.Status.Version; else if (ShowVersion) { - ManagerStatus.Message = CoreTools.Translate("{pm} version:").Replace("{pm}", Manager.Name); + ManagerStatus.Message = CoreTools.Translate("{pm} version:", new Dictionary{ { "pm", Manager.Name } }); LongVersion.Visibility = Visibility.Visible; } else @@ -215,14 +215,14 @@ void SetManagerStatus(PackageManager Manager, bool ShowVersion = false) else if (Manager.IsEnabled() && !Manager.Status.Found) { ManagerStatus.Severity = InfoBarSeverity.Error; - ManagerStatus.Title = CoreTools.Translate("{pm} was not found!").Replace("{pm}", Manager.Name); - ManagerStatus.Message = CoreTools.Translate("You may need to install {pm} in order to use it with WingetUI.").Replace("{pm}", Manager.Name); + ManagerStatus.Title = CoreTools.Translate("{pm} was not found!", new Dictionary{ { "pm", Manager.Name } }); + ManagerStatus.Message = CoreTools.Translate("You may need to install {pm} in order to use it with WingetUI.", new Dictionary{ { "pm", Manager.Name } }); } else if (!Manager.IsEnabled()) { ManagerStatus.Severity = InfoBarSeverity.Informational; - ManagerStatus.Title = CoreTools.Translate("{pm} is disabled").Replace("{pm}", Manager.Name); - ManagerStatus.Message = CoreTools.Translate("Enable it to install packages from {pm}.").Replace("{pm}", Manager.Name); + ManagerStatus.Title = CoreTools.Translate("{pm} is disabled", new Dictionary{ { "pm", Manager.Name } }); + ManagerStatus.Message = CoreTools.Translate("Enable it to install packages from {pm}.", new Dictionary{ { "pm", Manager.Name } }); } } diff --git a/src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml.cs b/src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml.cs index 7f6d1125e..347e42b68 100644 --- a/src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml.cs +++ b/src/UniGetUI/Interface/SoftwarePages/AbstractPackagesPage.xaml.cs @@ -103,7 +103,7 @@ protected string NoPackages_SubtitleText get { return NoPackages_SubtitleMainText + " " + - (SHOW_LAST_CHECKED_TIME ? CoreTools.Translate("(Last checked: {0})").Replace("{0}", LastPackageLoadTime.ToString()) : ""); + (SHOW_LAST_CHECKED_TIME ? CoreTools.Translate("(Last checked: {0})", LastPackageLoadTime.ToString()) : ""); } } @@ -113,10 +113,9 @@ protected string NoMatches_SubtitleText { get { - return CoreTools.Translate("{0} packages were found, {1} of which match the specified filters.") - .Replace("{0}", Packages.Count.ToString()) - .Replace("{1}", (FilteredPackages.Count()).ToString()) + " " + - (SHOW_LAST_CHECKED_TIME? CoreTools.Translate("(Last checked: {0})").Replace("{0}", LastPackageLoadTime.ToString()): ""); + return CoreTools.Translate("{0} packages were found, {1} of which match the specified filters.", + Packages.Count.ToString(), FilteredPackages.Count()) + + " " + (SHOW_LAST_CHECKED_TIME? CoreTools.Translate("(Last checked: {0})", LastPackageLoadTime.ToString()): ""); } } protected string FoundPackages_SubtitleText { get { return NoMatches_SubtitleText; } } @@ -178,7 +177,7 @@ public AbstractPackagesPage() }; - LocalPackagesNode = new TreeViewNode() { Content = CoreTools.Translate("Local"), IsExpanded = false }; + LocalPackagesNode = new TreeViewNode { Content = CoreTools.Translate("Local"), IsExpanded = false }; SourcesTreeView.Tapped += (s, e) => { @@ -307,7 +306,7 @@ protected void AddPackageToSourcesList(Package package) { UsedManagers.Add(source.Manager); TreeViewNode Node; - Node = new TreeViewNode() { Content = source.Manager.Name + " .", IsExpanded = false }; + Node = new TreeViewNode { Content = source.Manager.Name + " .", IsExpanded = false }; SourcesTreeView.RootNodes.Add(Node); // Smart way to decide whether to check a source or not. diff --git a/src/UniGetUI/Interface/SoftwarePages/NewDiscoverSoftwarePage.cs b/src/UniGetUI/Interface/SoftwarePages/NewDiscoverSoftwarePage.cs index 2db00d48f..d27e0d051 100644 --- a/src/UniGetUI/Interface/SoftwarePages/NewDiscoverSoftwarePage.cs +++ b/src/UniGetUI/Interface/SoftwarePages/NewDiscoverSoftwarePage.cs @@ -384,7 +384,7 @@ private async void ShowSharedPackage(string pId, string pSource) MainApp.Instance.MainWindow.Activate(); - MainApp.Instance.MainWindow.ShowLoadingDialog(CoreTools.Translate("Please wait...").Replace("{0}", pId)); + MainApp.Instance.MainWindow.ShowLoadingDialog(CoreTools.Translate("Please wait...", pId)); QueryIdRadio.IsChecked = true; QueryBlock.Text = pId; await LoadPackages(); @@ -415,7 +415,7 @@ private async void ShowSharedPackage(string pId, string pSource) c.XamlRoot = XamlRoot; c.Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style; c.Title = CoreTools.Translate("Package not found"); - c.Content = CoreTools.Translate("The package {0} from {1} was not found.").Replace("{0}", pId).Replace("{1}", pSource); + c.Content = CoreTools.Translate("The package {0} from {1} was not found.", pId, pSource); c.PrimaryButtonText = CoreTools.Translate("OK"); c.DefaultButton = ContentDialogButton.Primary; await MainApp.Instance.MainWindow.ShowDialogAsync(c); diff --git a/src/UniGetUI/Interface/SoftwarePages/NewInstalledPackagesPage.cs b/src/UniGetUI/Interface/SoftwarePages/NewInstalledPackagesPage.cs index 228de7238..e87ebd705 100644 --- a/src/UniGetUI/Interface/SoftwarePages/NewInstalledPackagesPage.cs +++ b/src/UniGetUI/Interface/SoftwarePages/NewInstalledPackagesPage.cs @@ -340,7 +340,7 @@ public async void ConfirmAndUninstall(Package package, InstallationOptions optio dialog.PrimaryButtonText = CoreTools.Translate("No"); dialog.SecondaryButtonText = CoreTools.Translate("Yes"); dialog.DefaultButton = ContentDialogButton.Primary; - dialog.Content = CoreTools.Translate("Do you really want to uninstall {0}?").Replace("{0}", package.Name); + dialog.Content = CoreTools.Translate("Do you really want to uninstall {0}?", package.Name); if (await MainApp.Instance.MainWindow.ShowDialogAsync(dialog) == ContentDialogResult.Secondary) MainApp.Instance.AddOperationToList(new UninstallPackageOperation(package, options)); @@ -366,14 +366,14 @@ public async void ConfirmAndUninstall(Package[] packages, bool AsAdmin = false, dialog.DefaultButton = ContentDialogButton.Primary; StackPanel p = new(); - p.Children.Add(new TextBlock() { Text = CoreTools.Translate("Do you really want to uninstall the following {0} packages?").Replace("{0}", packages.Length.ToString()), Margin = new Thickness(0, 0, 0, 5) }); + p.Children.Add(new TextBlock { Text = CoreTools.Translate("Do you really want to uninstall the following {0} packages?", packages.Length), Margin = new Thickness(0, 0, 0, 5) }); string pkgList = ""; foreach (Package package in packages) pkgList += " ● " + package.Name + "\x0a"; TextBlock PackageListTextBlock = new() { FontFamily = new Microsoft.UI.Xaml.Media.FontFamily("Consolas"), Text = pkgList }; - p.Children.Add(new ScrollView() { Content = PackageListTextBlock, MaxHeight = 200 }); + p.Children.Add(new ScrollView { Content = PackageListTextBlock, MaxHeight = 200 }); dialog.Content = p; @@ -408,7 +408,7 @@ public async Task BackupPackages() string fileName = Settings.GetValue("ChangeBackupFileName"); if (fileName == "") - fileName = CoreTools.Translate("{pcName} installed packages").Replace("{pcName}", Environment.MachineName); + fileName = CoreTools.Translate("{pcName} installed packages", new Dictionary{ { "pcName", Environment.MachineName } }); if (Settings.Get("EnableBackupTimestamping")) fileName += " " + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss"); diff --git a/src/UniGetUI/Interface/SoftwarePages/NewSoftwareUpdatesPage.cs b/src/UniGetUI/Interface/SoftwarePages/NewSoftwareUpdatesPage.cs index 655e30eea..9d84bf718 100644 --- a/src/UniGetUI/Interface/SoftwarePages/NewSoftwareUpdatesPage.cs +++ b/src/UniGetUI/Interface/SoftwarePages/NewSoftwareUpdatesPage.cs @@ -371,13 +371,13 @@ protected override async Task WhenPackagesLoaded(ReloadReason reason) if (upgradablePackages.Count == 1) { title = CoreTools.Translate("An update was found!"); - body = CoreTools.Translate("{0} is being updated to version {1}").Replace("{0}", upgradablePackages[0].Name).Replace("{1}", upgradablePackages[0].NewVersion); - attribution = CoreTools.Translate("You have currently version {0} installed").Replace("{0}", upgradablePackages[0].Version); + body = CoreTools.Translate("{0} is being updated to version {1}", upgradablePackages[0].Name, upgradablePackages[0].NewVersion); + attribution = CoreTools.Translate("You have currently version {0} installed", upgradablePackages[0].Version); } else { title = CoreTools.Translate("Updates found!"); - body = CoreTools.Translate("{0} packages are being updated").Replace("{0}", upgradablePackages.Count.ToString()); ; + body = CoreTools.Translate("{0} packages are being updated", upgradablePackages.Count); ; foreach (UpgradablePackage package in upgradablePackages) { attribution += package.Name + ", "; @@ -391,13 +391,13 @@ protected override async Task WhenPackagesLoaded(ReloadReason reason) if (upgradablePackages.Count == 1) { title = CoreTools.Translate("An update was found!"); - body = CoreTools.Translate("{0} can be updated to version {1}").Replace("{0}", upgradablePackages[0].Name).Replace("{1}", upgradablePackages[0].NewVersion); - attribution = CoreTools.Translate("You have currently version {0} installed").Replace("{0}", upgradablePackages[0].Version); + body = CoreTools.Translate("{0} can be updated to version {1}", upgradablePackages[0].Name, upgradablePackages[0].NewVersion); + attribution = CoreTools.Translate("You have currently version {0} installed", upgradablePackages[0].Version); } else { title = CoreTools.Translate("Updates found!"); - body = CoreTools.Translate("{0} packages can be updated").Replace("{0}", upgradablePackages.Count.ToString()); ; + body = CoreTools.Translate("{0} packages can be updated", upgradablePackages.Count); ; foreach (UpgradablePackage package in upgradablePackages) { attribution += package.Name + ", "; diff --git a/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml.cs b/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml.cs index 7fe75d516..b2f2b1b49 100644 --- a/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml.cs +++ b/src/UniGetUI/Interface/SoftwarePages/PackageBundle.xaml.cs @@ -63,7 +63,7 @@ public PackageBundlePage() PackageList = __package_list; LoadingProgressBar = __loading_progressbar; LoadingProgressBar.Visibility = Visibility.Collapsed; - LocalPackagesNode = new TreeViewNode() { Content = CoreTools.Translate("Local"), IsExpanded = false }; + LocalPackagesNode = new TreeViewNode { Content = CoreTools.Translate("Local"), IsExpanded = false }; Initialized = true; ReloadButton.Visibility = Visibility.Collapsed; FindButton.Click += (s, e) => { FilterPackages(QueryBlock.Text); }; @@ -178,7 +178,7 @@ protected void AddPackageToSourcesList(Package package) { UsedManagers.Add(source.Manager); TreeViewNode Node; - Node = new TreeViewNode() { Content = source.Manager.Name + " .", IsExpanded = false }; + Node = new TreeViewNode { Content = source.Manager.Name + " .", IsExpanded = false }; SourcesTreeView.RootNodes.Add(Node); SourcesTreeView.SelectedNodes.Add(Node); RootNodeForManager.Add(source.Manager, Node); @@ -335,7 +335,7 @@ public void FilterPackages(string query, bool StillLoading = false) { BackgroundText.Text = CoreTools.AutoTranslated("No results were found matching the input criteria"); SourcesPlaceholderText.Text = CoreTools.AutoTranslated("No packages were found"); - MainSubtitle.Text = CoreTools.Translate("{0} packages were found, {1} of which match the specified filters.").Replace("{0}", Packages.Count.ToString()).Replace("{1}", (MatchingList.Length - HiddenPackagesDueToSource).ToString()); + MainSubtitle.Text = CoreTools.Translate("{0} packages were found, {1} of which match the specified filters.", Packages.Count, MatchingList.Length - HiddenPackagesDueToSource); } BackgroundText.Visibility = Visibility.Visible; } @@ -344,7 +344,7 @@ public void FilterPackages(string query, bool StillLoading = false) else { BackgroundText.Visibility = Visibility.Collapsed; - MainSubtitle.Text = CoreTools.Translate("{0} packages were found, {1} of which match the specified filters.").Replace("{0}", Packages.Count.ToString()).Replace("{1}", (MatchingList.Length - HiddenPackagesDueToSource).ToString()); + MainSubtitle.Text = CoreTools.Translate("{0} packages were found, {1} of which match the specified filters.", Packages.Count, MatchingList.Length - HiddenPackagesDueToSource); } } @@ -420,7 +420,7 @@ public void GenerateToolBar() ToolBar.PrimaryCommands.Add(new AppBarSeparator()); ToolBar.PrimaryCommands.Add(InstallPackages); ToolBar.PrimaryCommands.Add(new AppBarSeparator()); - ToolBar.PrimaryCommands.Add(new AppBarElementContainer() { Content = new TextBlock() { HorizontalAlignment = HorizontalAlignment.Stretch } }); + ToolBar.PrimaryCommands.Add(new AppBarElementContainer { Content = new TextBlock { HorizontalAlignment = HorizontalAlignment.Stretch } }); ToolBar.PrimaryCommands.Add(SelectAll); ToolBar.PrimaryCommands.Add(SelectNone); ToolBar.PrimaryCommands.Add(new AppBarSeparator()); @@ -771,7 +771,7 @@ public async static Task GetBundleStringFromPackages(BundledPackage[] pa string ExportableData; if (formatType == BundleFormatType.JSON) - ExportableData = JsonSerializer.Serialize(exportable, new JsonSerializerOptions() { WriteIndented = true }); + ExportableData = JsonSerializer.Serialize(exportable, new JsonSerializerOptions { WriteIndented = true }); else if (formatType == BundleFormatType.YAML) { YamlDotNet.Serialization.ISerializer serializer = new YamlDotNet.Serialization.SerializerBuilder() diff --git a/src/UniGetUI/Interface/Widgets/Announcer.xaml.cs b/src/UniGetUI/Interface/Widgets/Announcer.xaml.cs index 6bb553e10..85b089dfa 100644 --- a/src/UniGetUI/Interface/Widgets/Announcer.xaml.cs +++ b/src/UniGetUI/Interface/Widgets/Announcer.xaml.cs @@ -95,18 +95,18 @@ public void SetText_Safe(string title, string body, string linkId, string linkNa public void SetText(string title, string body, string linkId, string linkName) { Paragraph paragraph = new(); - paragraph.Inlines.Add(new Run() { Text = title, FontSize = 24, FontWeight = new FontWeight(700), FontFamily = new FontFamily("Segoe UI Variable Display") }); + paragraph.Inlines.Add(new Run { Text = title, FontSize = 24, FontWeight = new FontWeight(700), FontFamily = new FontFamily("Segoe UI Variable Display") }); _textblock.Blocks.Clear(); _textblock.Blocks.Add(paragraph); paragraph = new(); foreach (string line in body.Split("\n")) { - paragraph.Inlines.Add(new Run() { Text = line + " " }); + paragraph.Inlines.Add(new Run { Text = line + " " }); paragraph.Inlines.Add(new LineBreak()); } Hyperlink link = new(); - link.Inlines.Add(new Run() { Text = linkName }); + link.Inlines.Add(new Run { Text = linkName }); link.NavigateUri = new Uri("https://marticliment.com/redirect?" + linkId); paragraph.Inlines[^1] = link; paragraph.Inlines.Add(new LineBreak()); @@ -119,7 +119,7 @@ public void SetText(string body) Paragraph paragraph = new(); foreach (string line in body.Split("\n")) { - paragraph.Inlines.Add(new Run() { Text = line }); + paragraph.Inlines.Add(new Run { Text = line }); paragraph.Inlines.Add(new LineBreak()); } _textblock.Blocks.Clear(); diff --git a/src/UniGetUI/Interface/Widgets/ComboboxCard.cs b/src/UniGetUI/Interface/Widgets/ComboboxCard.cs index 71b9695ee..f0ce3d761 100644 --- a/src/UniGetUI/Interface/Widgets/ComboboxCard.cs +++ b/src/UniGetUI/Interface/Widgets/ComboboxCard.cs @@ -72,7 +72,7 @@ public ComboboxCard() _combobox = new ComboBox(); _combobox.MinWidth = 200; - _combobox.SetBinding(ItemsControl.ItemsSourceProperty, new Binding() { Source = _elements }); + _combobox.SetBinding(ItemsControl.ItemsSourceProperty, new Binding { Source = _elements }); DefaultStyleKey = typeof(CheckboxCard); Content = _combobox; diff --git a/src/UniGetUI/Interface/Widgets/SourceManager.xaml.cs b/src/UniGetUI/Interface/Widgets/SourceManager.xaml.cs index 33c8cae8d..c7f53432b 100644 --- a/src/UniGetUI/Interface/Widgets/SourceManager.xaml.cs +++ b/src/UniGetUI/Interface/Widgets/SourceManager.xaml.cs @@ -49,7 +49,7 @@ public SourceManager(PackageManager Manager) if (!Manager.Capabilities.SupportsCustomSources) throw new Exception($"Attempted to create a SourceManager class from Manager {Manager.Name}, which does not support custom sources"); - Header.Text = CoreTools.Translate("Manage {0} sources").Replace("{0}", Manager.Properties.Name); + Header.Text = CoreTools.Translate("Manage {0} sources", Manager.Properties.Name); AddSourceButton.Content = CoreTools.Translate("Add source"); AddSourceButton.Click += async (sender, e) => { @@ -70,19 +70,19 @@ public SourceManager(PackageManager Manager) d.Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style; StackPanel p = new(); p.Spacing = 8; - p.Children.Add(new TextBlock() { Text = CoreTools.Translate("Select the source you want to add:") }); + p.Children.Add(new TextBlock { Text = CoreTools.Translate("Select the source you want to add:") }); p.Children.Add(SourcesCombo); TextBox SourceNameTextBox = new() { HorizontalAlignment = HorizontalAlignment.Stretch, Width = 400 }; TextBox SourceUrlTextBox = new() { HorizontalAlignment = HorizontalAlignment.Stretch }; StackPanel p1 = new() { Spacing = 2, HorizontalAlignment = HorizontalAlignment.Stretch }; - p1.Children.Add(new TextBlock() { Text = CoreTools.Translate("Source name:"), VerticalAlignment = VerticalAlignment.Center }); + p1.Children.Add(new TextBlock { Text = CoreTools.Translate("Source name:"), VerticalAlignment = VerticalAlignment.Center }); p1.Children.Add(SourceNameTextBox); StackPanel p2 = new() { Spacing = 2, HorizontalAlignment = HorizontalAlignment.Stretch }; - p2.Children.Add(new TextBlock() { Text = CoreTools.Translate("Source URL:"), VerticalAlignment = VerticalAlignment.Center }); + p2.Children.Add(new TextBlock { Text = CoreTools.Translate("Source URL:"), VerticalAlignment = VerticalAlignment.Center }); p2.Children.Add(SourceUrlTextBox); p.Children.Add(p1); diff --git a/src/UniGetUI/PackageEngine/Operations/OperationControl.xaml.cs b/src/UniGetUI/PackageEngine/Operations/OperationControl.xaml.cs index c602467e0..5b7f55a00 100644 --- a/src/UniGetUI/PackageEngine/Operations/OperationControl.xaml.cs +++ b/src/UniGetUI/PackageEngine/Operations/OperationControl.xaml.cs @@ -63,7 +63,7 @@ private WidgetLayout LayoutMode Grid.SetColumnSpan(ProgressIndicator, 4); Grid.SetRow(ProgressIndicator, 1); if (MainGrid.RowDefinitions.Count < 2) - MainGrid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); + MainGrid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); } else { @@ -221,7 +221,7 @@ public AbstractOperation() foreach (string line in ProcessOutput) { if (line.Contains(" | ")) - p.Inlines.Add(new Run() { Text = line.Replace(" | ", "").Trim() + "\x0a" }); + p.Inlines.Add(new Run { Text = line.Replace(" | ", "").Trim() + "\x0a" }); } LiveOutputTextBlock.Blocks.Add(p); await Task.Delay(100); @@ -248,11 +248,11 @@ public async void OpenLiveViewDialog() if (Status != OperationStatus.Failed) { if (line.Contains(" | ")) - p.Inlines.Add(new Run() { Text = line.Replace(" | ", "").Trim() + "\x0a" }); + p.Inlines.Add(new Run { Text = line.Replace(" | ", "").Trim() + "\x0a" }); } else { - p.Inlines.Add(new Run() { Text = line + "\x0a" }); + p.Inlines.Add(new Run { Text = line + "\x0a" }); } } LiveOutputTextBlock.Blocks.Add(p); @@ -326,7 +326,7 @@ protected virtual async Task WaitForAvailability() currentIndex = MainApp.Instance.OperationQueue.IndexOf(this); if (currentIndex != oldIndex) { - LineInfoText = CoreTools.Translate("Operation on queue (position {0})...").Replace("{0}", currentIndex.ToString()); + LineInfoText = CoreTools.Translate("Operation on queue (position {0})...", currentIndex); oldIndex = currentIndex; } await Task.Delay(100); diff --git a/src/UniGetUI/PackageEngine/Operations/PackageOperations.cs b/src/UniGetUI/PackageEngine/Operations/PackageOperations.cs index 481e8fe42..ecee194cd 100644 --- a/src/UniGetUI/PackageEngine/Operations/PackageOperations.cs +++ b/src/UniGetUI/PackageEngine/Operations/PackageOperations.cs @@ -4,6 +4,7 @@ using Microsoft.UI.Xaml.Documents; using Microsoft.UI.Xaml.Media; using System; +using System.Collections.Generic; using System.Diagnostics; using System.Threading.Tasks; using UniGetUI.Core; @@ -65,7 +66,7 @@ protected override async Task WaitForAvailability() currentIndex = MainApp.Instance.OperationQueue.IndexOf(this); if (currentIndex != oldIndex) { - LineInfoText = CoreTools.Translate("Operation on queue (position {0})...").Replace("{0}", currentIndex.ToString()); + LineInfoText = CoreTools.Translate("Operation on queue (position {0})...", currentIndex); oldIndex = currentIndex; } await Task.Delay(100); @@ -126,7 +127,7 @@ protected override OperationVeredict GetProcessVeredict(int ReturnCode, string[] protected override async Task HandleFailure() { - LineInfoText = CoreTools.Translate("{package} installation failed").Replace("{package}", Package.Name); + LineInfoText = CoreTools.Translate("{package} installation failed", new Dictionary{ { "package", Package.Name } }); Package.SetTag(PackageTag.Failed); @@ -137,7 +138,7 @@ protected override async Task HandleFailure() .AddArgument("action", "OpenUniGetUI") .AddArgument("notificationId", CoreData.VolatileNotificationIdCounter) .AddText(CoreTools.Translate("Installation failed")) - .AddText(CoreTools.Translate("{package} could not be installed").Replace("{package}", Package.Name)).Show(); + .AddText(CoreTools.Translate("{package} could not be installed", new Dictionary{ { "package", Package.Name } })).Show(); } catch (Exception ex) @@ -150,16 +151,16 @@ protected override async Task HandleFailure() dialog.XamlRoot = XamlRoot; dialog.Resources["ContentDialogMaxWidth"] = 750; dialog.Resources["ContentDialogMaxHeight"] = 1000; - dialog.Title = CoreTools.Translate("{package} installation failed").Replace("{package}", Package.Name); + dialog.Title = CoreTools.Translate("{package} installation failed", new Dictionary{ { "package", Package.Name } }); StackPanel panel = new() { Spacing = 16 }; - panel.Children.Add(new TextBlock() { TextWrapping = TextWrapping.WrapWholeWords, Text = CoreTools.Translate("{package} could not be installed").Replace("{package}", Package.Name) + ". " + CoreTools.Translate("Please see the Command-line Output or refer to the Operation History for further information about the issue.") }); + panel.Children.Add(new TextBlock { TextWrapping = TextWrapping.WrapWholeWords, Text = CoreTools.Translate("{package} could not be installed", new Dictionary{ { "package", Package.Name } }) + ". " + CoreTools.Translate("Please see the Command-line Output or refer to the Operation History for further information about the issue.") }); Expander expander = new() { CornerRadius = new CornerRadius(8) }; StackPanel HeaderPanel = new() { Orientation = Orientation.Horizontal, Spacing = 8 }; HeaderPanel.Children.Add(new LocalIcon("console") { VerticalAlignment = VerticalAlignment.Center, Height = 24, Width = 24, HorizontalAlignment = HorizontalAlignment.Left }); - HeaderPanel.Children.Add(new TextBlock() { Text = CoreTools.Translate("Command-line Output"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }); + HeaderPanel.Children.Add(new TextBlock { Text = CoreTools.Translate("Command-line Output"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }); expander.Header = HeaderPanel; expander.HorizontalAlignment = HorizontalAlignment.Stretch; @@ -170,7 +171,7 @@ protected override async Task HandleFailure() sv.MaxHeight = 500; Paragraph par = new(); foreach (string line in ProcessOutput) - par.Inlines.Add(new Run() { Text = line + "\x0a" }); + par.Inlines.Add(new Run { Text = line + "\x0a" }); output.Blocks.Add(par); sv.Content = output; @@ -191,7 +192,7 @@ protected override async Task HandleFailure() protected override async Task HandleSuccess() { - LineInfoText = CoreTools.Translate("{package} was installed successfully").Replace("{package}", Package.Name); + LineInfoText = CoreTools.Translate("{package} was installed successfully", new Dictionary{ { "package", Package.Name } }); Package.SetTag(PackageTag.AlreadyInstalled); MainApp.Instance.MainWindow.NavigationPage.InstalledPage.AddInstalledPackage(Package); @@ -204,7 +205,7 @@ protected override async Task HandleSuccess() .AddArgument("action", "OpenUniGetUI") .AddArgument("notificationId", CoreData.VolatileNotificationIdCounter) .AddText(CoreTools.Translate("Installation succeeded")) - .AddText(CoreTools.Translate("{package} was installed successfully").Replace("{package}", Package.Name)).Show(); + .AddText(CoreTools.Translate("{package} was installed successfully", new Dictionary{ { "package", Package.Name } })).Show(); } catch (Exception ex) @@ -218,7 +219,7 @@ protected override async Task HandleSuccess() protected override async void Initialize() { - OperationTitle = CoreTools.Translate("{package} Installation").Replace("{package}", Package.Name); + OperationTitle = CoreTools.Translate("{package} Installation", new Dictionary{ { "package", Package.Name } }); IconSource = await Package.GetIconUrl(); } } @@ -271,7 +272,7 @@ protected override OperationVeredict GetProcessVeredict(int ReturnCode, string[] protected override async Task HandleFailure() { - LineInfoText = CoreTools.Translate("{package} update failed. Click here for more details.").Replace("{package}", Package.Name); + LineInfoText = CoreTools.Translate("{package} update failed. Click here for more details.", new Dictionary{ { "package", Package.Name } }); Package.SetTag(PackageTag.Failed); @@ -282,7 +283,7 @@ protected override async Task HandleFailure() .AddArgument("action", "OpenUniGetUI") .AddArgument("notificationId", CoreData.VolatileNotificationIdCounter) .AddText(CoreTools.Translate("Update failed")) - .AddText(CoreTools.Translate("{package} could not be updated").Replace("{package}", Package.Name)).Show(); + .AddText(CoreTools.Translate("{package} could not be updated", new Dictionary{ { "package", Package.Name } })).Show(); } catch (Exception ex) @@ -295,16 +296,16 @@ protected override async Task HandleFailure() dialog.XamlRoot = XamlRoot; dialog.Resources["ContentDialogMaxWidth"] = 750; dialog.Resources["ContentDialogMaxHeight"] = 1000; - dialog.Title = CoreTools.Translate("{package} update failed").Replace("{package}", Package.Name); + dialog.Title = CoreTools.Translate("{package} update failed", new Dictionary{ { "package", Package.Name } }); StackPanel panel = new() { Spacing = 16 }; - panel.Children.Add(new TextBlock() { TextWrapping = TextWrapping.WrapWholeWords, Text = CoreTools.Translate("{package} could not be updated").Replace("{package}", Package.Name) + ". " + CoreTools.Translate("Please see the Command-line Output or refer to the Operation History for further information about the issue.") }); + panel.Children.Add(new TextBlock { TextWrapping = TextWrapping.WrapWholeWords, Text = CoreTools.Translate("{package} could not be updated", new Dictionary{ { "package", Package.Name } }) + ". " + CoreTools.Translate("Please see the Command-line Output or refer to the Operation History for further information about the issue.") }); Expander expander = new() { CornerRadius = new CornerRadius(8) }; StackPanel HeaderPanel = new() { Orientation = Orientation.Horizontal, Spacing = 8 }; HeaderPanel.Children.Add(new LocalIcon("console") { VerticalAlignment = VerticalAlignment.Center, Height = 24, Width = 24, HorizontalAlignment = HorizontalAlignment.Left }); - HeaderPanel.Children.Add(new TextBlock() { Text = CoreTools.Translate("Command-line Output"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }); + HeaderPanel.Children.Add(new TextBlock { Text = CoreTools.Translate("Command-line Output"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }); expander.Header = HeaderPanel; expander.HorizontalAlignment = HorizontalAlignment.Stretch; @@ -315,7 +316,7 @@ protected override async Task HandleFailure() sv.MaxHeight = 500; Paragraph par = new(); foreach (string line in ProcessOutput) - par.Inlines.Add(new Run() { Text = line + "\x0a" }); + par.Inlines.Add(new Run { Text = line + "\x0a" }); output.Blocks.Add(par); sv.Content = output; @@ -336,7 +337,7 @@ protected override async Task HandleFailure() protected override async Task HandleSuccess() { - LineInfoText = CoreTools.Translate("{package} was updated successfully").Replace("{package}", Package.Name); + LineInfoText = CoreTools.Translate("{package} was updated successfully", new Dictionary{ { "package", Package.Name } }); Package.GetInstalledPackage()?.SetTag(PackageTag.Default); Package.GetAvailablePackage()?.SetTag(PackageTag.AlreadyInstalled); @@ -353,7 +354,7 @@ protected override async Task HandleSuccess() .AddArgument("action", "OpenUniGetUI") .AddArgument("notificationId", CoreData.VolatileNotificationIdCounter) .AddText(CoreTools.Translate("Update succeeded")) - .AddText(CoreTools.Translate("{package} was updated successfully").Replace("{package}", Package.Name)).Show(); + .AddText(CoreTools.Translate("{package} was updated successfully", new Dictionary{ { "package", Package.Name } })).Show(); } catch (Exception ex) @@ -370,7 +371,7 @@ protected override async Task HandleSuccess() protected override async void Initialize() { - OperationTitle = CoreTools.Translate("{package} Update").Replace("{package}", Package.Name); + OperationTitle = CoreTools.Translate("{package} Update", new Dictionary{ { "package", Package.Name } }); IconSource = await Package.GetIconUrl(); } } @@ -424,7 +425,7 @@ protected override OperationVeredict GetProcessVeredict(int ReturnCode, string[] protected override async Task HandleFailure() { - LineInfoText = CoreTools.Translate("{package} uninstall failed").Replace("{package}", Package.Name); + LineInfoText = CoreTools.Translate("{package} uninstall failed", new Dictionary{ { "package", Package.Name } }); Package.SetTag(PackageTag.Failed); @@ -435,7 +436,7 @@ protected override async Task HandleFailure() .AddArgument("action", "OpenUniGetUI") .AddArgument("notificationId", CoreData.VolatileNotificationIdCounter) .AddText(CoreTools.Translate("Uninstall failed")) - .AddText(CoreTools.Translate("{package} could not be uninstalled").Replace("{package}", Package.Name)).Show(); + .AddText(CoreTools.Translate("{package} could not be uninstalled", new Dictionary{ { "package", Package.Name } })).Show(); } catch (Exception ex) @@ -449,16 +450,16 @@ protected override async Task HandleFailure() dialog.XamlRoot = XamlRoot; dialog.Resources["ContentDialogMaxWidth"] = 750; dialog.Resources["ContentDialogMaxHeight"] = 1000; - dialog.Title = CoreTools.Translate("{package} uninstall failed").Replace("{package}", Package.Name); + dialog.Title = CoreTools.Translate("{package} uninstall failed", new Dictionary{ { "package", Package.Name } }); StackPanel panel = new() { Spacing = 16 }; - panel.Children.Add(new TextBlock() { TextWrapping = TextWrapping.WrapWholeWords, Text = CoreTools.Translate("{package} could not be uninstalled").Replace("{package}", Package.Name) + ". " + CoreTools.Translate("Please see the Command-line Output or refer to the Operation History for further information about the issue.") }); + panel.Children.Add(new TextBlock { TextWrapping = TextWrapping.WrapWholeWords, Text = CoreTools.Translate("{package} could not be uninstalled", new Dictionary{ { "package", Package.Name } }) + ". " + CoreTools.Translate("Please see the Command-line Output or refer to the Operation History for further information about the issue.") }); Expander expander = new() { CornerRadius = new CornerRadius(8) }; StackPanel HeaderPanel = new() { Orientation = Orientation.Horizontal, Spacing = 8 }; HeaderPanel.Children.Add(new LocalIcon("console") { VerticalAlignment = VerticalAlignment.Center, Height = 24, Width = 24, HorizontalAlignment = HorizontalAlignment.Left }); - HeaderPanel.Children.Add(new TextBlock() { Text = CoreTools.Translate("Command-line Output"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }); + HeaderPanel.Children.Add(new TextBlock { Text = CoreTools.Translate("Command-line Output"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }); expander.Header = HeaderPanel; expander.HorizontalAlignment = HorizontalAlignment.Stretch; @@ -469,7 +470,7 @@ protected override async Task HandleFailure() sv.MaxHeight = 500; Paragraph par = new(); foreach (string line in ProcessOutput) - par.Inlines.Add(new Run() { Text = line + "\x0a" }); + par.Inlines.Add(new Run { Text = line + "\x0a" }); output.Blocks.Add(par); sv.Content = output; @@ -490,7 +491,7 @@ protected override async Task HandleFailure() protected override async Task HandleSuccess() { - LineInfoText = CoreTools.Translate("{package} was uninstalled successfully").Replace("{package}", Package.Name); + LineInfoText = CoreTools.Translate("{package} was uninstalled successfully", new Dictionary{ { "package", Package.Name } }); Package.GetAvailablePackage()?.SetTag(PackageTag.Default); MainApp.Instance.MainWindow.NavigationPage.UpdatesPage.RemoveCorrespondingPackages(Package); @@ -503,7 +504,7 @@ protected override async Task HandleSuccess() .AddArgument("action", "OpenUniGetUI") .AddArgument("notificationId", CoreData.VolatileNotificationIdCounter) .AddText(CoreTools.Translate("Uninstall succeeded")) - .AddText(CoreTools.Translate("{package} was uninstalled successfully").Replace("{package}", Package.Name)).Show(); + .AddText(CoreTools.Translate("{package} was uninstalled successfully", new Dictionary{ { "package", Package.Name } })).Show(); } catch (Exception ex) @@ -517,7 +518,7 @@ protected override async Task HandleSuccess() protected override async void Initialize() { - OperationTitle = CoreTools.Translate("{package} Uninstall").Replace("{package}", Package.Name); + OperationTitle = CoreTools.Translate("{package} Uninstall", new Dictionary{ { "package", Package.Name } }); IconSource = await Package.GetIconUrl(); } } diff --git a/src/UniGetUI/PackageEngine/Operations/SourceOperations.cs b/src/UniGetUI/PackageEngine/Operations/SourceOperations.cs index 516460f34..668408424 100644 --- a/src/UniGetUI/PackageEngine/Operations/SourceOperations.cs +++ b/src/UniGetUI/PackageEngine/Operations/SourceOperations.cs @@ -4,6 +4,7 @@ using Microsoft.UI.Xaml.Documents; using Microsoft.UI.Xaml.Media; using System; +using System.Collections.Generic; using System.Diagnostics; using System.Threading.Tasks; using UniGetUI.Core; @@ -76,7 +77,7 @@ protected override OperationVeredict GetProcessVeredict(int ReturnCode, string[] protected override async Task HandleFailure() { - LineInfoText = CoreTools.Translate("Could not add source {source} to {manager}").Replace("{source}", Source.Name).Replace("{manager}", Source.Manager.Name); + LineInfoText = CoreTools.Translate("Could not add source {source} to {manager}", new Dictionary{ { "source", Source.Name }, { "manager", Source.Manager.Name } }); if (!Settings.Get("DisableErrorNotifications") && !Settings.Get("DisableNotifications")) try { @@ -84,7 +85,7 @@ protected override async Task HandleFailure() .AddArgument("action", "OpenUniGetUI") .AddArgument("notificationId", CoreData.VolatileNotificationIdCounter) .AddText(CoreTools.Translate("Installation failed")) - .AddText(CoreTools.Translate("Could not add source {source} to {manager}").Replace("{source}", Source.Name).Replace("{manager}", Source.Manager.Name)).Show(); + .AddText(CoreTools.Translate("Could not add source {source} to {manager}", new Dictionary{ { "source", Source.Name }, { "manager", Source.Manager.Name } })).Show(); } catch (Exception ex) @@ -100,13 +101,13 @@ protected override async Task HandleFailure() dialog.Title = CoreTools.Translate("Source addition failed"); StackPanel panel = new() { Spacing = 16 }; - panel.Children.Add(new TextBlock() { TextWrapping = TextWrapping.WrapWholeWords, Text = CoreTools.Translate("Could not add source {source} to {manager}").Replace("{source}", Source.Name).Replace("{manager}", Source.Manager.Name) + ". " + CoreTools.Translate("Please see the Command-line Output or refer to the Operation History for further information about the issue.") }); + panel.Children.Add(new TextBlock { TextWrapping = TextWrapping.WrapWholeWords, Text = CoreTools.Translate("Could not add source {source} to {manager}", new Dictionary{ { "source", Source.Name }, { "manager", Source.Manager.Name } }) + ". " + CoreTools.Translate("Please see the Command-line Output or refer to the Operation History for further information about the issue.") }); Expander expander = new() { CornerRadius = new CornerRadius(8) }; StackPanel HeaderPanel = new() { Orientation = Orientation.Horizontal, Spacing = 8 }; HeaderPanel.Children.Add(new LocalIcon("console") { VerticalAlignment = VerticalAlignment.Center, Height = 24, Width = 24, HorizontalAlignment = HorizontalAlignment.Left }); - HeaderPanel.Children.Add(new TextBlock() { Text = CoreTools.Translate("Command-line Output"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }); + HeaderPanel.Children.Add(new TextBlock { Text = CoreTools.Translate("Command-line Output"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }); expander.Header = HeaderPanel; expander.HorizontalAlignment = HorizontalAlignment.Stretch; @@ -117,7 +118,7 @@ protected override async Task HandleFailure() sv.MaxHeight = 500; Paragraph par = new(); foreach (string line in ProcessOutput) - par.Inlines.Add(new Run() { Text = line + "\x0a" }); + par.Inlines.Add(new Run { Text = line + "\x0a" }); output.Blocks.Add(par); sv.Content = output; @@ -139,16 +140,15 @@ protected override async Task HandleFailure() protected override async Task HandleSuccess() { OperationSucceeded?.Invoke(this, new EventArgs()); - LineInfoText = CoreTools.Translate("The source {source} was added to {manager} successfully").Replace("{source}", Source.Name).Replace("{manager}", Source.Manager.Name); + LineInfoText = CoreTools.Translate("The source {source} was added to {manager} successfully", new Dictionary{ { "source", Source.Name }, { "manager", Source.Manager.Name } }); if (!Settings.Get("DisableSuccessNotifications") && !Settings.Get("DisableNotifications")) - - try - { + + try{ new ToastContentBuilder() .AddArgument("action", "OpenUniGetUI") .AddArgument("notificationId", CoreData.VolatileNotificationIdCounter) .AddText(CoreTools.Translate("Addition succeeded")) - .AddText(CoreTools.Translate("The source {source} was added to {manager} successfully").Replace("{source}", Source.Name).Replace("{manager}", Source.Manager.Name)).Show(); + .AddText(CoreTools.Translate("The source {source} was added to {manager} successfully", new Dictionary{ { "source", Source.Name }, { "manager", Source.Manager.Name } })).Show(); } catch (Exception ex) @@ -162,7 +162,7 @@ protected override async Task HandleSuccess() protected override void Initialize() { - OperationTitle = CoreTools.Translate("Adding source {source} to {manager}").Replace("{source}", Source.Name).Replace("{manager}", Source.Manager.Name); + OperationTitle = CoreTools.Translate("Adding source {source} to {manager}", new Dictionary{ { "source", Source.Name }, { "manager", Source.Manager.Name } }); IconSource = new Uri("ms-appx:///Assets/Images/" + Source.Manager.Properties.ColorIconId + ".png"); } } @@ -215,13 +215,13 @@ protected override OperationVeredict GetProcessVeredict(int ReturnCode, string[] protected override async Task HandleFailure() { - LineInfoText = CoreTools.Translate("Could not remove source {source} from {manager}").Replace("{source}", Source.Name).Replace("{manager}", Source.Manager.Name); + LineInfoText = CoreTools.Translate("Could not remove source {source} from {manager}", new Dictionary{ { "source", Source.Name }, { "manager", Source.Manager.Name } }); if (!Settings.Get("DisableErrorNotifications") && !Settings.Get("DisableNotifications")) new ToastContentBuilder() .AddArgument("action", "OpenUniGetUI") .AddArgument("notificationId", CoreData.VolatileNotificationIdCounter) .AddText(CoreTools.Translate("Removal failed")) - .AddText(CoreTools.Translate("Could not remove source {source} from {manager}").Replace("{source}", Source.Name).Replace("{manager}", Source.Manager.Name)).Show(); + .AddText(CoreTools.Translate("Could not remove source {source} from {manager}", new Dictionary{ { "source", Source.Name }, { "manager", Source.Manager.Name } })).Show(); ContentDialog dialog = new(); dialog.Style = Application.Current.Resources["DefaultContentDialogStyle"] as Style; @@ -231,13 +231,13 @@ protected override async Task HandleFailure() dialog.Title = CoreTools.Translate("Source removal failed"); StackPanel panel = new() { Spacing = 16 }; - panel.Children.Add(new TextBlock() { TextWrapping = TextWrapping.WrapWholeWords, Text = CoreTools.Translate("Could not remove source {source} from {manager}").Replace("{source}", Source.Name).Replace("{manager}", Source.Manager.Name) + ". " + CoreTools.Translate("Please see the Command-line Output or refer to the Operation History for further information about the issue.") }); + panel.Children.Add(new TextBlock { TextWrapping = TextWrapping.WrapWholeWords, Text = CoreTools.Translate("Could not remove source {source} from {manager}", new Dictionary{ { "source", Source.Name }, { "manager", Source.Manager.Name } }) + ". " + CoreTools.Translate("Please see the Command-line Output or refer to the Operation History for further information about the issue.") }); Expander expander = new() { CornerRadius = new CornerRadius(8) }; StackPanel HeaderPanel = new() { Orientation = Orientation.Horizontal, Spacing = 8 }; HeaderPanel.Children.Add(new LocalIcon("console") { VerticalAlignment = VerticalAlignment.Center, Height = 24, Width = 24, HorizontalAlignment = HorizontalAlignment.Left }); - HeaderPanel.Children.Add(new TextBlock() { Text = CoreTools.Translate("Command-line Output"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }); + HeaderPanel.Children.Add(new TextBlock { Text = CoreTools.Translate("Command-line Output"), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }); expander.Header = HeaderPanel; expander.HorizontalAlignment = HorizontalAlignment.Stretch; @@ -248,7 +248,7 @@ protected override async Task HandleFailure() sv.MaxHeight = 500; Paragraph par = new(); foreach (string line in ProcessOutput) - par.Inlines.Add(new Run() { Text = line + "\x0a" }); + par.Inlines.Add(new Run { Text = line + "\x0a" }); output.Blocks.Add(par); sv.Content = output; @@ -270,15 +270,14 @@ protected override async Task HandleFailure() protected override async Task HandleSuccess() { OperationSucceeded?.Invoke(this, new EventArgs()); - LineInfoText = CoreTools.Translate("The source {source} was removed from {manager} successfully").Replace("{source}", Source.Name).Replace("{manager}", Source.Manager.Name); + LineInfoText = CoreTools.Translate("The source {source} was removed from {manager} successfully", new Dictionary{ { "source", Source.Name }, { "manager", Source.Manager.Name } }); if (!Settings.Get("DisableSuccessNotifications") && !Settings.Get("DisableNotifications")) - try - { - new ToastContentBuilder() - .AddArgument("action", "OpenUniGetUI") - .AddArgument("notificationId", CoreData.VolatileNotificationIdCounter) - .AddText(CoreTools.Translate("Removal succeeded")) - .AddText(CoreTools.Translate("The source {source} was removed from {manager} successfully").Replace("{source}", Source.Name).Replace("{manager}", Source.Manager.Name)).Show(); + try { + new ToastContentBuilder() + .AddArgument("action", "OpenUniGetUI") + .AddArgument("notificationId", CoreData.VolatileNotificationIdCounter) + .AddText(CoreTools.Translate("Removal succeeded")) + .AddText(CoreTools.Translate("The source {source} was removed from {manager} successfully", new Dictionary{ { "source", Source.Name }, { "manager", Source.Manager.Name } })).Show(); } catch (Exception ex) @@ -292,7 +291,7 @@ protected override async Task HandleSuccess() protected override void Initialize() { - OperationTitle = CoreTools.Translate("Removing source {source} from {manager}").Replace("{source}", Source.Name).Replace("{manager}", Source.Manager.Name); + OperationTitle = CoreTools.Translate("Removing source {source} from {manager}", new Dictionary{ { "source", Source.Name }, { "manager", Source.Manager.Name } }); IconSource = new Uri("ms-appx:///Assets/Images/" + Source.Manager.Properties.ColorIconId + ".png"); } }