Added text content to the I18N system

This commit is contained in:
Thorsten Sommer 2025-05-30 18:57:34 +02:00
parent ec0c783cfc
commit ccc1742eee
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 57 additions and 53 deletions

View File

@ -1,9 +1,11 @@
<MudDialog> @inherits MSGComponentBase
<MudDialog>
<DialogContent> <DialogContent>
@if (this.isInstallationInProgress) @if (this.isInstallationInProgress)
{ {
<MudText Typo="Typo.h4" Class="mb-3"> <MudText Typo="Typo.h4" Class="mb-3">
Please wait for the installation to complete... @T("Please wait for the installation to complete...")
</MudText> </MudText>
<MudProgressLinear Color="Color.Primary" Indeterminate="@true" Size="Size.Large" Rounded="@true"/> <MudProgressLinear Color="Color.Primary" Indeterminate="@true" Size="Size.Large" Rounded="@true"/>
} }
@ -11,15 +13,15 @@
{ {
<div class="mb-4"> <div class="mb-4">
<MudJustifiedText Typo="Typo.body1" Class="mb-2"> <MudJustifiedText Typo="Typo.body1" Class="mb-2">
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.")
</MudJustifiedText> </MudJustifiedText>
<MudJustifiedText Typo="Typo.body1"> <MudJustifiedText Typo="Typo.body1">
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.")
</MudJustifiedText> </MudJustifiedText>
</div> </div>
<MudExpansionPanels Class="mb-3" MultiExpansion="@false" Outlined="false" Elevation="0"> <MudExpansionPanels Class="mb-3" MultiExpansion="@false" Outlined="false" Elevation="0">
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Verified" HeaderText="View the GNU General Public License v2 (GPL)" MaxHeight="300" ExpandedChanged="this.WhenExpandingLicence"> <ExpansionPanel HeaderIcon="@Icons.Material.Filled.Verified" HeaderText="@T("View the GNU General Public License v2 (GPL)")" MaxHeight="300" ExpandedChanged="this.WhenExpandingLicence">
@if (this.isLoadingLicence) @if (this.isLoadingLicence)
{ {
<MudSkeleton/> <MudSkeleton/>
@ -32,26 +34,26 @@
} }
</ExpansionPanel> </ExpansionPanel>
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.AutoFixHigh" HeaderText="Automatic installation" IsExpanded="true"> <ExpansionPanel HeaderIcon="@Icons.Material.Filled.AutoFixHigh" HeaderText="@T("Automatic installation")" IsExpanded="true">
<MudJustifiedText Typo="Typo.body1"> <MudJustifiedText Typo="Typo.body1">
Pandoc is distributed under the <MudLink Href="https://github.com/jgm/pandoc/blob/main/COPYING.md" Target="_blank">GNU General Public License v2 (GPL)</MudLink>. 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 <MudLink Href=\"https://github.com/jgm/pandoc/blob/main/COPYING.md\" Target=\"_blank\">GNU General Public License v2 (GPL)</MudLink>. 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."))
</MudJustifiedText> </MudJustifiedText>
<MudButton OnClick="InstallPandocAsync" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Medium" StartIcon="@Icons.Material.Filled.InstallDesktop"> <MudButton OnClick="this.InstallPandocAsync" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Medium" StartIcon="@Icons.Material.Filled.InstallDesktop">
Accept the GPL and start the installation @T("Accept the GPL and start the installation")
</MudButton> </MudButton>
</ExpansionPanel> </ExpansionPanel>
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Build" HeaderText="Manual installation" ExpandedChanged="this.WhenExpandingManualInstallation"> <ExpansionPanel HeaderIcon="@Icons.Material.Filled.Build" HeaderText="@T("Manual installation")" ExpandedChanged="this.WhenExpandingManualInstallation">
<MudJustifiedText Typo="Typo.body1" Class="mb-2"> <MudJustifiedText Typo="Typo.body1" Class="mb-2">
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.")
</MudJustifiedText> </MudJustifiedText>
<MudExpansionPanels Outlined="false" Elevation="0"> <MudExpansionPanels Outlined="false" Elevation="0">
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.AppRegistration" HeaderText="Download installer" IsExpanded="true"> <ExpansionPanel HeaderIcon="@Icons.Material.Filled.AppRegistration" HeaderText="@T("Download installer")" IsExpanded="true">
<MudList T="string"> <MudList T="string">
<MudListItem T="string" Class="mb-2"> <MudListItem T="string" Class="mb-2">
<MudJustifiedText Typo="Typo.body1"> <MudJustifiedText Typo="Typo.body1">
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.")
</MudJustifiedText> </MudJustifiedText>
<CodeTabs @bind-SelectedIndex="this.selectedInstallerIndex"> <CodeTabs @bind-SelectedIndex="this.selectedInstallerIndex">
<CodeBlock Title="Windows">pandoc-@(LATEST_PANDOC_VERSION)-windows-x86_64.msi</CodeBlock> <CodeBlock Title="Windows">pandoc-@(LATEST_PANDOC_VERSION)-windows-x86_64.msi</CodeBlock>
@ -61,17 +63,17 @@
</MudListItem> </MudListItem>
<MudListItem T="string"> <MudListItem T="string">
<MudJustifiedText Typo="Typo.body1"> <MudJustifiedText Typo="Typo.body1">
Execute the installer and follow the instructions. @T("Execute the installer and follow the instructions.")
</MudJustifiedText> </MudJustifiedText>
</MudListItem> </MudListItem>
</MudList> </MudList>
<MudJustifiedText Class="mb-3" Typo="Typo.body1"> <MudJustifiedText Class="mb-3" Typo="Typo.body1">
Pandoc is distributed under the <MudLink Href="https://github.com/jgm/pandoc/blob/main/COPYING.md" Target="_blank">GNU General Public License v2 (GPL)</MudLink>. 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 <MudLink Href=\"https://github.com/jgm/pandoc/blob/main/COPYING.md\" Target=\"_blank\">GNU General Public License v2 (GPL)</MudLink>. 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."))
</MudJustifiedText> </MudJustifiedText>
<MudButton Href="@this.downloadUrlInstaller" Target="_blank" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Medium" StartIcon="@Icons.Material.Filled.Downloading"> <MudButton Href="@this.downloadUrlInstaller" Target="_blank" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Medium" StartIcon="@Icons.Material.Filled.Downloading">
Accept the GPL and download the installer @T("Accept the GPL and download the installer")
</MudButton> </MudButton>
</ExpansionPanel> </ExpansionPanel>
@ -79,13 +81,13 @@
<MudList T="string"> <MudList T="string">
<MudListItem T="string" Class="mb-2"> <MudListItem T="string" Class="mb-2">
<MudJustifiedText Typo="Typo.body1"> <MudJustifiedText Typo="Typo.body1">
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.")
</MudJustifiedText> </MudJustifiedText>
</MudListItem> </MudListItem>
<MudListItem T="string" Class="mb-2"> <MudListItem T="string" Class="mb-2">
<MudJustifiedText Typo="Typo.body1"> <MudJustifiedText Typo="Typo.body1">
Extract the archive to a folder of your choice, e.g.: @T("Extract the archive to a folder of your choice, e.g.:")
</MudJustifiedText> </MudJustifiedText>
<CodeTabs @bind-SelectedIndex="this.selectedArchiveIndex"> <CodeTabs @bind-SelectedIndex="this.selectedArchiveIndex">
<CodeBlock Title="Windows">C:\Users\%USERNAME%\pandoc</CodeBlock> <CodeBlock Title="Windows">C:\Users\%USERNAME%\pandoc</CodeBlock>
@ -96,7 +98,7 @@
<MudListItem T="string" Class="mb-2"> <MudListItem T="string" Class="mb-2">
<MudJustifiedText Typo="Typo.body1"> <MudJustifiedText Typo="Typo.body1">
Open the folder and copy the full path to the <CodeBlock IsInline="true">@PandocProcessBuilder.PandocExecutableName</CodeBlock> file into your clipboard: @((MarkupString)T("Open the folder and copy the full path to the <CodeBlock IsInline=\"true\">@PandocProcessBuilder.PandocExecutableName</CodeBlock> file into your clipboard:"))
</MudJustifiedText> </MudJustifiedText>
<CodeTabs @bind-SelectedIndex="this.selectedArchiveIndex"> <CodeTabs @bind-SelectedIndex="this.selectedArchiveIndex">
<CodeBlock Title="Windows">C:\Users\%USERNAME%\pandoc\pandoc-@(LATEST_PANDOC_VERSION)</CodeBlock> <CodeBlock Title="Windows">C:\Users\%USERNAME%\pandoc\pandoc-@(LATEST_PANDOC_VERSION)</CodeBlock>
@ -107,7 +109,7 @@
<MudListItem T="string"> <MudListItem T="string">
<MudJustifiedText Typo="Typo.body1"> <MudJustifiedText Typo="Typo.body1">
Add the copied path to your system's or user's <CodeBlock IsInline="true">PATH</CodeBlock> environment variable, restart your terminal, and check the installation by typing <CodeBlock IsInline="@true">pandoc --version</CodeBlock> into your terminal: @((MarkupString)T("Add the copied path to your system's or user's <CodeBlock IsInline=\"true\">PATH</CodeBlock> environment variable, restart your terminal, and check the installation by typing <CodeBlock IsInline=\"true\">pandoc --version</CodeBlock> into your terminal:"))
</MudJustifiedText> </MudJustifiedText>
<CodeTabs @bind-SelectedIndex="this.selectedArchiveIndex"> <CodeTabs @bind-SelectedIndex="this.selectedArchiveIndex">
<CodeBlock Title="Windows">> pandoc.exe --version<br/>> pandoc @(LATEST_PANDOC_VERSION)</CodeBlock> <CodeBlock Title="Windows">> pandoc.exe --version<br/>> pandoc @(LATEST_PANDOC_VERSION)</CodeBlock>
@ -119,12 +121,12 @@
<MudText Class="mb-3" Typo="Typo.caption"> <MudText Class="mb-3" Typo="Typo.caption">
<MudJustifiedText Typo="Typo.body1"> <MudJustifiedText Typo="Typo.body1">
Pandoc is distributed under the <MudLink Href="https://github.com/jgm/pandoc/blob/main/COPYING.md" Target="_blank">GNU General Public License v2 (GPL)</MudLink>. 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 <MudLink Href=\"https://github.com/jgm/pandoc/blob/main/COPYING.md\" Target=\"_blank\">GNU General Public License v2 (GPL)</MudLink>. 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."))
</MudJustifiedText> </MudJustifiedText>
</MudText> </MudText>
<MudButton Href="@this.downloadUrlArchive" Target="_blank" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Medium" StartIcon="@Icons.Material.Filled.Downloading"> <MudButton Href="@this.downloadUrlArchive" Target="_blank" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Medium" StartIcon="@Icons.Material.Filled.Downloading">
Accept the GPL and download the archive @T("Accept the GPL and download the archive")
</MudButton> </MudButton>
</ExpansionPanel> </ExpansionPanel>
</MudExpansionPanels> </MudExpansionPanels>
@ -154,7 +156,7 @@
<MudStack Row="true" AlignItems="AlignItems.Center"> <MudStack Row="true" AlignItems="AlignItems.Center">
<MudIcon Style="width: 2.5em; height: 2.5em;" Icon="@Icons.Material.Filled.Check" Color="Color.Success"/> <MudIcon Style="width: 2.5em; height: 2.5em;" Icon="@Icons.Material.Filled.Check" Color="Color.Success"/>
<MudJustifiedText Typo="Typo.body1"> <MudJustifiedText Typo="Typo.body1">
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.")
</MudJustifiedText> </MudJustifiedText>
</MudStack> </MudStack>
break; break;
@ -163,8 +165,7 @@
<MudStack Row="true" AlignItems="AlignItems.Center"> <MudStack Row="true" AlignItems="AlignItems.Center">
<MudIcon Style="width: 3.5em; height: 3.5em;" Icon="@Icons.Material.Filled.Error" Color="Color.Error"/> <MudIcon Style="width: 3.5em; height: 3.5em;" Icon="@Icons.Material.Filled.Error" Color="Color.Error"/>
<MudJustifiedText Typo="Typo.body1"> <MudJustifiedText Typo="Typo.body1">
Pandoc is installed, but the version is too old and does not meet the requirements of @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.")
MindWork AI Studio. AI Studio can help you install a newer version.
</MudJustifiedText> </MudJustifiedText>
</MudStack> </MudStack>
break; break;
@ -173,7 +174,7 @@
<MudStack Row="true" AlignItems="AlignItems.Center"> <MudStack Row="true" AlignItems="AlignItems.Center">
<MudIcon Style="width: 3.5em; height: 3.5em;" Icon="@Icons.Material.Filled.Error" Color="Color.Error"/> <MudIcon Style="width: 3.5em; height: 3.5em;" Icon="@Icons.Material.Filled.Error" Color="Color.Error"/>
<MudJustifiedText Typo="Typo.body1"> <MudJustifiedText Typo="Typo.body1">
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.")
</MudJustifiedText> </MudJustifiedText>
</MudStack> </MudStack>
break; break;
@ -186,23 +187,23 @@
@if (this.isInstallationInProgress) @if (this.isInstallationInProgress)
{ {
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled"> <MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
Close @T("Close")
</MudButton> </MudButton>
} }
else if (this.ShowInstallationPage) else if (this.ShowInstallationPage)
{ {
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled"> <MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
Close @T("Close")
</MudButton> </MudButton>
<MudButton Color="Color.Warning" OnClick="@this.RejectLicense" Variant="Variant.Filled" Size="Size.Medium"> <MudButton Color="Color.Warning" OnClick="@this.RejectLicense" Variant="Variant.Filled" Size="Size.Medium">
Reject the GPL licence @T("Reject the GPL licence")
</MudButton> </MudButton>
} }
else else
{ {
<MudButton OnClick="@this.Cancel" Variant="Variant.Filled"> <MudButton OnClick="@this.Cancel" Variant="Variant.Filled">
Close @T("Close")
</MudButton> </MudButton>
@if (this.pandocInstallation != default) @if (this.pandocInstallation != default)
@ -212,13 +213,13 @@
case { CheckWasSuccessful: true, IsAvailable: false }: case { CheckWasSuccessful: true, IsAvailable: false }:
case { CheckWasSuccessful: false, IsAvailable: false }: case { CheckWasSuccessful: false, IsAvailable: false }:
<MudButton Color="Color.Primary" OnClick="@this.ProceedToInstallation" Variant="Variant.Filled" Size="Size.Medium"> <MudButton Color="Color.Primary" OnClick="@this.ProceedToInstallation" Variant="Variant.Filled" Size="Size.Medium">
Proceed to the installation @T("Proceed to the installation")
</MudButton> </MudButton>
break; break;
case { CheckWasSuccessful: true, IsAvailable: true }: case { CheckWasSuccessful: true, IsAvailable: true }:
<MudButton Color="Color.Default" OnClick="@this.ProceedToInstallation" Variant="Variant.Filled" Size="Size.Medium"> <MudButton Color="Color.Default" OnClick="@this.ProceedToInstallation" Variant="Variant.Filled" Size="Size.Medium">
Re-install Pandoc @T("Re-install Pandoc")
</MudButton> </MudButton>
break; break;
} }

View File

@ -1,5 +1,6 @@
using System.Reflection; using System.Reflection;
using AIStudio.Components;
using AIStudio.Tools.Metadata; using AIStudio.Tools.Metadata;
using AIStudio.Tools.Services; using AIStudio.Tools.Services;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
@ -8,7 +9,7 @@ using SharedTools;
namespace AIStudio.Dialogs; namespace AIStudio.Dialogs;
public partial class PandocDialog : ComponentBase public partial class PandocDialog : MSGComponentBase
{ {
private static readonly Assembly ASSEMBLY = Assembly.GetExecutingAssembly(); private static readonly Assembly ASSEMBLY = Assembly.GetExecutingAssembly();
private static readonly MetaDataArchitectureAttribute META_DATA_ARCH = ASSEMBLY.GetCustomAttribute<MetaDataArchitectureAttribute>()!; private static readonly MetaDataArchitectureAttribute META_DATA_ARCH = ASSEMBLY.GetCustomAttribute<MetaDataArchitectureAttribute>()!;
@ -81,13 +82,13 @@ public partial class PandocDialog : ComponentBase
private async Task RejectLicense() 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 var dialogParameters = new DialogParameters
{ {
{ "Message", message }, { "Message", message },
}; };
var dialogReference = await this.DialogService.ShowAsync<ConfirmDialog>("Reject Pandoc's Licence", dialogParameters, DialogOptions.FULLSCREEN); var dialogReference = await this.DialogService.ShowAsync<ConfirmDialog>(T("Reject Pandoc's Licence"), dialogParameters, DialogOptions.FULLSCREEN);
var dialogResult = await dialogReference.Result; var dialogResult = await dialogReference.Result;
if (dialogResult is null || dialogResult.Canceled) if (dialogResult is null || dialogResult.Canceled)
dialogReference.Close(); dialogReference.Close();
@ -115,7 +116,7 @@ public partial class PandocDialog : ComponentBase
} }
catch (Exception ex) 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); LOG.LogError("Error loading GPL license text: {ErrorMessage}", ex.Message);
} }
finally finally

View File

@ -13,6 +13,8 @@ namespace AIStudio.Tools;
public static partial class Pandoc 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 Assembly ASSEMBLY = Assembly.GetExecutingAssembly();
private static readonly MetaDataArchitectureAttribute META_DATA_ARCH = ASSEMBLY.GetCustomAttribute<MetaDataArchitectureAttribute>()!; private static readonly MetaDataArchitectureAttribute META_DATA_ARCH = ASSEMBLY.GetCustomAttribute<MetaDataArchitectureAttribute>()!;
private static readonly RID CPU_ARCHITECTURE = META_DATA_ARCH.Architecture.ToRID(); private static readonly RID CPU_ARCHITECTURE = META_DATA_ARCH.Architecture.ToRID();
@ -45,10 +47,10 @@ public static partial class Pandoc
if (process == null) if (process == null)
{ {
if (showMessages) 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"); 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(); var output = await process.StandardOutput.ReadToEndAsync();
@ -56,20 +58,20 @@ public static partial class Pandoc
if (process.ExitCode != 0) if (process.ExitCode != 0)
{ {
if (showMessages) 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); 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); var versionMatch = PandocCmdRegex().Match(output);
if (!versionMatch.Success) if (!versionMatch.Success)
{ {
if (showMessages) 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); 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; var versions = versionMatch.Groups[1].Value;
@ -79,25 +81,25 @@ public static partial class Pandoc
if (installedVersion >= MINIMUM_REQUIRED_VERSION) if (installedVersion >= MINIMUM_REQUIRED_VERSION)
{ {
if (showMessages) 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()); 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); return new(true, string.Empty, true, installedVersionString, preparedProcess.IsLocal);
} }
if (showMessages) 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()); 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) catch (Exception e)
{ {
if (showMessages) 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); 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); var response = await client.GetAsync(uri);
if (!response.IsSuccessStatusCode) 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); 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; return;
} }
@ -153,14 +155,14 @@ public static partial class Pandoc
} }
else 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); LOG.LogError("Pandoc was not installed, the archive is unknown: url='{0}'", uri);
return; return;
} }
File.Delete(pandocTempDownloadFile); 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); LOG.LogInformation("Pandoc v{0} was installed successfully.", latestVersion);
} }
catch (Exception ex) catch (Exception ex)
@ -196,7 +198,7 @@ public static partial class Pandoc
if (!response.IsSuccessStatusCode) if (!response.IsSuccessStatusCode)
{ {
LOG.LogError("Code {StatusCode}: Could not fetch Pandoc's latest page: {Response}", response.StatusCode, response.RequestMessage); 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(); return FALLBACK_VERSION.ToString();
} }
@ -205,7 +207,7 @@ public static partial class Pandoc
if (!versionMatch.Success) if (!versionMatch.Success)
{ {
LOG.LogError("The latest version regex returned nothing: {0}", versionMatch.Groups.ToString()); 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(); return FALLBACK_VERSION.ToString();
} }
@ -280,7 +282,7 @@ public static partial class Pandoc
return $"{baseUri}arm64-macOS.pkg"; return $"{baseUri}arm64-macOS.pkg";
default: 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; return string.Empty;
} }
} }