diff --git a/app/MindWork AI Studio/Dialogs/PandocDialog.razor b/app/MindWork AI Studio/Dialogs/PandocDialog.razor index 35911116..fe4d08f9 100644 --- a/app/MindWork AI Studio/Dialogs/PandocDialog.razor +++ b/app/MindWork AI Studio/Dialogs/PandocDialog.razor @@ -1,9 +1,11 @@ - +@inherits MSGComponentBase + + @if (this.isInstallationInProgress) { - Please wait for the installation to complete... + @T("Please wait for the installation to complete...") } @@ -11,15 +13,15 @@ {
- AI Studio uses the free and open-source third-party app Pandoc to process and retrieve data from local Office files (such as Word files) or to generate Office documents. + @T("AI Studio uses the free and open-source third-party app Pandoc to process and retrieve data from local Office files (such as Word files) or to generate Office documents.") - Unfortunately, Pandoc's GPL license isn't compatible with the AI Studios licenses. However, software under the GPL is free to use and free of charge. You'll need to accept the GPL license before we can download and install Pandoc for you automatically (recommended). Alternatively, you might download it yourself using the instructions below or install it otherwise, e.g., by using a package manager of your operating system. + @T("Unfortunately, Pandoc's GPL license isn't compatible with the AI Studios licenses. However, software under the GPL is free to use and free of charge. You'll need to accept the GPL license before we can download and install Pandoc for you automatically (recommended). Alternatively, you might download it yourself using the instructions below or install it otherwise, e.g., by using a package manager of your operating system.")
- + @if (this.isLoadingLicence) { @@ -32,26 +34,26 @@ } - + - Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking "Accept GPL and Install," you agree to the terms of the GPL license, and Pandoc will be installed automatically for you. Software under GPL is free of charge and free to use. + @((MarkupString)T("Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking \"Accept GPL and Install,\" you agree to the terms of the GPL license, and Pandoc will be installed automatically for you. Software under GPL is free of charge and free to use.")) - - Accept the GPL and start the installation + + @T("Accept the GPL and start the installation") - + - If you want to install Pandoc yourself, follow one of these two guides. The first guide uses an installer and is available for Windows and macOS. Alternatively, you might use a package manager of your operating system to install Pandoc. + @T("If you want to install Pandoc yourself, follow one of these two guides. The first guide uses an installer and is available for Windows and macOS. Alternatively, you might use a package manager of your operating system to install Pandoc.") - + - Accept the terms of the GPL license and download the latest installer with the download button below. Eventually, you need to allow the download of the installer in the download window. + @T("Accept the terms of the GPL license and download the latest installer with the download button below. Eventually, you need to allow the download of the installer in the download window.") pandoc-@(LATEST_PANDOC_VERSION)-windows-x86_64.msi @@ -61,17 +63,17 @@ - Execute the installer and follow the instructions. + @T("Execute the installer and follow the instructions.") - Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking "Accept GPL and download installer," you agree to the terms of the GPL license. Software under GPL is free of charge and free to use. + @((MarkupString)T("Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking \"Accept GPL and download installer,\" you agree to the terms of the GPL license. Software under GPL is free of charge and free to use.")) - Accept the GPL and download the installer + @T("Accept the GPL and download the installer") @@ -79,13 +81,13 @@ - Accept the terms of the GPL license and download the latest archive with the download button below. + @T("Accept the terms of the GPL license and download the latest archive with the download button below.") - Extract the archive to a folder of your choice, e.g.: + @T("Extract the archive to a folder of your choice, e.g.:") C:\Users\%USERNAME%\pandoc @@ -96,7 +98,7 @@ - Open the folder and copy the full path to the @PandocProcessBuilder.PandocExecutableName file into your clipboard: + @((MarkupString)T("Open the folder and copy the full path to the @PandocProcessBuilder.PandocExecutableName file into your clipboard:")) C:\Users\%USERNAME%\pandoc\pandoc-@(LATEST_PANDOC_VERSION) @@ -107,7 +109,7 @@ - Add the copied path to your system's or user's PATH environment variable, restart your terminal, and check the installation by typing pandoc --version into your terminal: + @((MarkupString)T("Add the copied path to your system's or user's PATH environment variable, restart your terminal, and check the installation by typing pandoc --version into your terminal:")) > pandoc.exe --version
> pandoc @(LATEST_PANDOC_VERSION)
@@ -119,12 +121,12 @@ - Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking "Accept GPL and archive," you agree to the terms of the GPL license. Software under GPL is free of charge and free to use. + @((MarkupString)T("Pandoc is distributed under the GNU General Public License v2 (GPL). By clicking \"Accept GPL and archive,\" you agree to the terms of the GPL license. Software under GPL is free of charge and free to use.")) - Accept the GPL and download the archive + @T("Accept the GPL and download the archive")
@@ -154,7 +156,7 @@ - Pandoc is installed and the version meets the requirements of MindWork AI Studio. + @T("Pandoc is installed and the version meets the requirements of MindWork AI Studio.") break; @@ -163,8 +165,7 @@ - Pandoc is installed, but the version is too old and does not meet the requirements of - MindWork AI Studio. AI Studio can help you install a newer version. + @T("Pandoc is installed, but the version is too old and does not meet the requirements of MindWork AI Studio. AI Studio can help you install a newer version.") break; @@ -173,7 +174,7 @@ - Pandoc doesn't seem to be installed on this system. AI Studio can help you install the correct version. + @T("Pandoc doesn't seem to be installed on this system. AI Studio can help you install the correct version.") break; @@ -186,23 +187,23 @@ @if (this.isInstallationInProgress) { - Close + @T("Close") } else if (this.ShowInstallationPage) { - Close + @T("Close") - Reject the GPL licence + @T("Reject the GPL licence") } else { - Close + @T("Close") @if (this.pandocInstallation != default) @@ -212,13 +213,13 @@ case { CheckWasSuccessful: true, IsAvailable: false }: case { CheckWasSuccessful: false, IsAvailable: false }: - Proceed to the installation + @T("Proceed to the installation") break; case { CheckWasSuccessful: true, IsAvailable: true }: - Re-install Pandoc + @T("Re-install Pandoc") break; } diff --git a/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs b/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs index 002505c9..ae048016 100644 --- a/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs @@ -1,5 +1,6 @@ using System.Reflection; +using AIStudio.Components; using AIStudio.Tools.Metadata; using AIStudio.Tools.Services; using Microsoft.AspNetCore.Components; @@ -8,7 +9,7 @@ using SharedTools; namespace AIStudio.Dialogs; -public partial class PandocDialog : ComponentBase +public partial class PandocDialog : MSGComponentBase { private static readonly Assembly ASSEMBLY = Assembly.GetExecutingAssembly(); private static readonly MetaDataArchitectureAttribute META_DATA_ARCH = ASSEMBLY.GetCustomAttribute()!; @@ -81,13 +82,13 @@ public partial class PandocDialog : ComponentBase private async Task RejectLicense() { - var message = "Pandoc is open-source and free, but if you reject its license, you can't install it and some MindWork AI Studio features will be limited (like the integration of Office files) or unavailable (like the generation of Office files). You can change your decision anytime. Are you sure you want to reject the license?"; + var message = T("Pandoc is open-source and free, but if you reject its license, you can't install it and some MindWork AI Studio features will be limited (like the integration of Office files) or unavailable (like the generation of Office files). You can change your decision anytime. Are you sure you want to reject the license?"); var dialogParameters = new DialogParameters { { "Message", message }, }; - var dialogReference = await this.DialogService.ShowAsync("Reject Pandoc's Licence", dialogParameters, DialogOptions.FULLSCREEN); + var dialogReference = await this.DialogService.ShowAsync(T("Reject Pandoc's Licence"), dialogParameters, DialogOptions.FULLSCREEN); var dialogResult = await dialogReference.Result; if (dialogResult is null || dialogResult.Canceled) dialogReference.Close(); @@ -115,7 +116,7 @@ public partial class PandocDialog : ComponentBase } catch (Exception ex) { - this.licenseText = "Error loading license text, please consider following the links to read the GPL."; + this.licenseText = T("Error loading license text, please consider following the links to read the GPL."); LOG.LogError("Error loading GPL license text: {ErrorMessage}", ex.Message); } finally diff --git a/app/MindWork AI Studio/Tools/Pandoc.cs b/app/MindWork AI Studio/Tools/Pandoc.cs index 5f9a8b84..3c12e618 100644 --- a/app/MindWork AI Studio/Tools/Pandoc.cs +++ b/app/MindWork AI Studio/Tools/Pandoc.cs @@ -13,6 +13,8 @@ namespace AIStudio.Tools; public static partial class Pandoc { + private static string TB(string fallbackEN) => PluginSystem.I18N.I.T(fallbackEN, typeof(Pandoc).Namespace, nameof(Pandoc)); + private static readonly Assembly ASSEMBLY = Assembly.GetExecutingAssembly(); private static readonly MetaDataArchitectureAttribute META_DATA_ARCH = ASSEMBLY.GetCustomAttribute()!; private static readonly RID CPU_ARCHITECTURE = META_DATA_ARCH.Architecture.ToRID(); @@ -45,10 +47,10 @@ public static partial class Pandoc if (process == null) { if (showMessages) - await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Help, "Was not able to check the Pandoc installation.")); + await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Help, TB("Was not able to check the Pandoc installation."))); LOG.LogInformation("The Pandoc process was not started, it was null"); - return new(false, "Was not able to check the Pandoc installation.", false, string.Empty, preparedProcess.IsLocal); + return new(false, TB("Was not able to check the Pandoc installation."), false, string.Empty, preparedProcess.IsLocal); } var output = await process.StandardOutput.ReadToEndAsync(); @@ -56,20 +58,20 @@ public static partial class Pandoc if (process.ExitCode != 0) { if (showMessages) - await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Error, "Pandoc is not available on the system or the process had issues.")); + await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Error, TB("Pandoc is not available on the system or the process had issues."))); LOG.LogError("The Pandoc process was exited with code {ProcessExitCode}", process.ExitCode); - return new(false, "Pandoc is not available on the system or the process had issues.", false, string.Empty, preparedProcess.IsLocal); + return new(false, TB("Pandoc is not available on the system or the process had issues."), false, string.Empty, preparedProcess.IsLocal); } var versionMatch = PandocCmdRegex().Match(output); if (!versionMatch.Success) { if (showMessages) - await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Terminal, "Was not able to validate the Pandoc installation.")); + await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Terminal, TB("Was not able to validate the Pandoc installation."))); LOG.LogError("Pandoc --version returned an invalid format: {Output}", output); - return new(false, "Was not able to validate the Pandoc installation.", false, string.Empty, preparedProcess.IsLocal); + return new(false, TB("Was not able to validate the Pandoc installation."), false, string.Empty, preparedProcess.IsLocal); } var versions = versionMatch.Groups[1].Value; @@ -79,25 +81,25 @@ public static partial class Pandoc if (installedVersion >= MINIMUM_REQUIRED_VERSION) { if (showMessages) - await MessageBus.INSTANCE.SendSuccess(new(Icons.Material.Filled.CheckCircle, $"Pandoc v{installedVersionString} is installed.")); + await MessageBus.INSTANCE.SendSuccess(new(Icons.Material.Filled.CheckCircle, string.Format(TB("Pandoc v{0} is installed."), installedVersionString))); LOG.LogInformation("Pandoc v{0} is installed and matches the required version (v{1})", installedVersionString, MINIMUM_REQUIRED_VERSION.ToString()); return new(true, string.Empty, true, installedVersionString, preparedProcess.IsLocal); } if (showMessages) - await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Build, $"Pandoc v{installedVersionString} is installed, but it doesn't match the required version (v{MINIMUM_REQUIRED_VERSION.ToString()}).")); + await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Build, string.Format(TB("Pandoc v{0} is installed, but it doesn't match the required version (v{1})."), installedVersionString, MINIMUM_REQUIRED_VERSION.ToString()))); LOG.LogWarning("Pandoc v{0} is installed, but it does not match the required version (v{1})", installedVersionString, MINIMUM_REQUIRED_VERSION.ToString()); - return new(true, $"Pandoc v{installedVersionString} is installed, but it does not match the required version (v{MINIMUM_REQUIRED_VERSION.ToString()}).", false, installedVersionString, preparedProcess.IsLocal); + return new(true, string.Format(TB("Pandoc v{0} is installed, but it does not match the required version (v{1})."), installedVersionString, MINIMUM_REQUIRED_VERSION.ToString()), false, installedVersionString, preparedProcess.IsLocal); } catch (Exception e) { if (showMessages) - await MessageBus.INSTANCE.SendError(new (@Icons.Material.Filled.AppsOutage, "It seems that Pandoc is not installed.")); + await MessageBus.INSTANCE.SendError(new (@Icons.Material.Filled.AppsOutage, TB("It seems that Pandoc is not installed."))); LOG.LogError("Pandoc is not installed and threw an exception: {0}", e.Message); - return new(false, "It seems that Pandoc is not installed.", false, string.Empty, false); + return new(false, TB("It seems that Pandoc is not installed."), false, string.Empty, false); } } @@ -131,7 +133,7 @@ public static partial class Pandoc var response = await client.GetAsync(uri); if (!response.IsSuccessStatusCode) { - await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Error, "Pandoc was not installed successfully, because the archive was not found.")); + await MessageBus.INSTANCE.SendError(new(Icons.Material.Filled.Error, TB("Pandoc was not installed successfully, because the archive was not found."))); LOG.LogError("Pandoc was not installed successfully, because the archive was not found (status code {0}): url='{1}', message='{2}'", response.StatusCode, uri, response.RequestMessage); return; } @@ -153,14 +155,14 @@ public static partial class Pandoc } else { - await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Error, "Pandoc was not installed successfully, because the archive type is unknown.")); + await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Error, TB("Pandoc was not installed successfully, because the archive type is unknown."))); LOG.LogError("Pandoc was not installed, the archive is unknown: url='{0}'", uri); return; } File.Delete(pandocTempDownloadFile); - await MessageBus.INSTANCE.SendSuccess(new(Icons.Material.Filled.CheckCircle, $"Pandoc v{latestVersion} was installed successfully.")); + await MessageBus.INSTANCE.SendSuccess(new(Icons.Material.Filled.CheckCircle, string.Format(TB("Pandoc v{0} was installed successfully."), latestVersion))); LOG.LogInformation("Pandoc v{0} was installed successfully.", latestVersion); } catch (Exception ex) @@ -196,7 +198,7 @@ public static partial class Pandoc if (!response.IsSuccessStatusCode) { LOG.LogError("Code {StatusCode}: Could not fetch Pandoc's latest page: {Response}", response.StatusCode, response.RequestMessage); - await MessageBus.INSTANCE.SendWarning(new (Icons.Material.Filled.Warning, $"The latest pandoc version was not found, installing version {FALLBACK_VERSION.ToString()} instead.")); + await MessageBus.INSTANCE.SendWarning(new (Icons.Material.Filled.Warning, string.Format(TB("The latest Pandoc version was not found, installing version {0} instead."), FALLBACK_VERSION.ToString()))); return FALLBACK_VERSION.ToString(); } @@ -205,7 +207,7 @@ public static partial class Pandoc if (!versionMatch.Success) { LOG.LogError("The latest version regex returned nothing: {0}", versionMatch.Groups.ToString()); - await MessageBus.INSTANCE.SendWarning(new (Icons.Material.Filled.Warning, $"The latest pandoc version was not found, installing version {FALLBACK_VERSION.ToString()} instead.")); + await MessageBus.INSTANCE.SendWarning(new (Icons.Material.Filled.Warning, string.Format(TB("The latest Pandoc version was not found, installing version {0} instead."), FALLBACK_VERSION.ToString()))); return FALLBACK_VERSION.ToString(); } @@ -280,7 +282,7 @@ public static partial class Pandoc return $"{baseUri}arm64-macOS.pkg"; default: - await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Terminal, $"Installers are not available on {CPU_ARCHITECTURE.ToUserFriendlyName()} systems.")); + await MessageBus.INSTANCE.SendError(new (Icons.Material.Filled.Terminal, string.Format(TB("Installers are not available on {0} systems."), CPU_ARCHITECTURE.ToUserFriendlyName()))); return string.Empty; } }