mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-14 07:08:27 +00:00
Added the choice between formal and informal address to the whole app (#1200)
This commit is contained in:
1 parent
382db4b8d0
commit
c9a376f742
342 files changed
+14378
-1893
No files matched your search
@@ -3,7 +3,7 @@
|
||||
@inherits AssistantBaseCore<AIStudio.Dialogs.Settings.SettingsDialogI18N>
|
||||
|
||||
<EnumSelection T="CommonLanguages" NameFunc="@(language => language.NameSelecting)" @bind-Value="@this.selectedTargetLanguage" ValidateSelection="@this.ValidatingTargetLanguage" Icon="@AppIcons.LANGUAGE" Label="@T("Target language")" AllowOther="@true" OtherValue="CommonLanguages.OTHER" @bind-OtherInput="@this.customTargetLanguage" ValidateOther="@this.ValidateCustomLanguage" LabelOther="@T("Custom target language")" SelectionUpdated="_ => this.OnChangedLanguage()" Disabled="@this.IsProcessing" />
|
||||
<ConfigurationSelect OptionDescription="@T("Language plugin used for comparision")" SelectedValue="@(() => this.selectedLanguagePluginId)" Data="@ConfigurationSelectDataFactory.GetLanguagesData()" SelectionUpdate="@(async void (id) => await this.OnLanguagePluginChanged(id))" OptionHelp="@T("Select the language plugin used for comparision.")" Disabled="@(() => this.IsProcessing)"/>
|
||||
<ConfigurationSelect OptionDescription="@T("Language plugin used for comparision")" SelectedValue="@(() => this.selectedLanguagePluginId)" Data="@ConfigurationSelectDataFactory.GetLanguagesData()" SelectionUpdate="@(async void (id) => await this.OnLanguagePluginChanged(id))" OptionHelp="@TA("Select the language plugin used for comparision.")" Disabled="@(() => this.IsProcessing)"/>
|
||||
@if (this.isLoading)
|
||||
{
|
||||
<MudText Typo="Typo.body1" Class="mb-6">
|
||||
@@ -76,7 +76,7 @@ else if (!this.isLoading && string.IsNullOrWhiteSpace(this.loadingIssue))
|
||||
@if (this.selectedTargetLanguage is CommonLanguages.EN_US)
|
||||
{
|
||||
<MudJustifiedText Typo="Typo.body1" Class="mb-6">
|
||||
@T("Please note: neither is a translation needed nor performed for English (USA). Anyway, you might want to generate the related Lua code.")
|
||||
@TA("Please note: neither is a translation needed nor performed for English (USA). Anyway, you might want to generate the related Lua code.")
|
||||
</MudJustifiedText>
|
||||
}
|
||||
else
|
||||
|
||||
@@ -15,7 +15,7 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
|
||||
|
||||
protected override string Title => T("Localization");
|
||||
|
||||
protected override string Description => T("Translate MindWork AI Studio text content into another language.");
|
||||
protected override string Description => TA("Translate MindWork AI Studio text content into another language.");
|
||||
|
||||
// This assistant writes language plugins, so no chat continues its conversation:
|
||||
protected override ChatSystemPromptChoice ChatSystemPrompt => ChatSystemPromptChoice.AI_STUDIO_DEFAULT;
|
||||
@@ -224,12 +224,12 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
|
||||
this.localizationPossible = false;
|
||||
if (PluginFactory.RunningPlugins.FirstOrDefault(n => n is PluginLanguage && n.Id == this.selectedLanguagePluginId) is not PluginLanguage comparisonPlugin)
|
||||
{
|
||||
this.loadingIssue = string.Format(T("Was not able to load the language plugin for comparison ({0}). Please select a valid, loaded & running language plugin."), this.selectedLanguagePluginId);
|
||||
this.loadingIssue = string.Format(TA("Was not able to load the language plugin for comparison ({0}). Please select a valid, loaded & running language plugin."), this.selectedLanguagePluginId);
|
||||
this.selectedLanguagePlugin = null;
|
||||
}
|
||||
else if (comparisonPlugin.IETFTag != this.selectedTargetLanguage.IETFTag)
|
||||
{
|
||||
this.loadingIssue = string.Format(T("The selected language plugin for comparison uses the IETF tag '{0}' which does not match the selected target language '{1}'. Please select a valid, loaded & running language plugin which matches the target language."), comparisonPlugin.IETFTag, this.selectedTargetLanguage.IETFTag);
|
||||
this.loadingIssue = string.Format(TA("The selected language plugin for comparison uses the IETF tag '{0}', which does not match the selected target language '{1}'. Please select a valid, loaded & running language plugin which matches the target language."), comparisonPlugin.IETFTag, this.selectedTargetLanguage.IETFTag);
|
||||
this.selectedLanguagePlugin = null;
|
||||
}
|
||||
else
|
||||
@@ -246,7 +246,7 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
|
||||
{
|
||||
if (this.selectedLanguagePlugin is null)
|
||||
{
|
||||
this.loadingIssue = T("Please select a language plugin for comparison.");
|
||||
this.loadingIssue = TA("Please select a language plugin for comparison.");
|
||||
this.localizationPossible = false;
|
||||
this.isLoading = false;
|
||||
this.StateHasChanged();
|
||||
@@ -273,7 +273,7 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
|
||||
break;
|
||||
|
||||
case NoPlugin:
|
||||
this.loadingIssue = T("Was not able to load the I18N plugin. Please check the plugin code.");
|
||||
this.loadingIssue = TA("Was not able to load the I18N plugin. Please check the plugin code.");
|
||||
break;
|
||||
|
||||
case { IsValid: false } plugin when plugin.Issues.Any():
|
||||
@@ -313,7 +313,7 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
|
||||
private string? ValidatingTargetLanguage(CommonLanguages language)
|
||||
{
|
||||
if(language == CommonLanguages.AS_IS)
|
||||
return T("Please select a target language.");
|
||||
return TA("Please select a target language.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -321,7 +321,7 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
|
||||
private string? ValidateCustomLanguage(string language)
|
||||
{
|
||||
if(this.selectedTargetLanguage == CommonLanguages.OTHER && string.IsNullOrWhiteSpace(language))
|
||||
return T("Please provide a custom language.");
|
||||
return TA("Please provide a custom language.");
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -408,7 +408,15 @@ public partial class AssistantI18N : AssistantBaseCore<SettingsDialogI18N>
|
||||
|
||||
if(this.CancellationTokenSource!.IsCancellationRequested)
|
||||
return;
|
||||
|
||||
|
||||
//
|
||||
// English addresses everybody alike, so its informal variants read like the
|
||||
// formal texts of the plugin, also where the plugin words a text differently
|
||||
// than the source code does:
|
||||
//
|
||||
if (this.selectedTargetLanguage is CommonLanguages.EN_US)
|
||||
I18NAddressPrompt.AlignInformalVariants(this.localizedContent);
|
||||
|
||||
//
|
||||
// Phase 2: Create the Lua code. Each comment names the English text, which
|
||||
// allTexts.lua holds for every key of the result. The English language plugin
|
||||
|
||||
@@ -40,6 +40,24 @@ public static class I18NAddressPrompt
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gives every informal variant the words of its formal text, for a language with one form of address only.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// English addresses everybody alike, yet its language plugin may word a text differently than the source code
|
||||
/// does. An informal variant taken from the source code would then differ from the formal text, and the language
|
||||
/// would offer the choice of address, see <see cref="AIStudio.Tools.PluginSystem.LanguagePluginExtensions"/>.
|
||||
/// </remarks>
|
||||
/// <param name="content">All texts of the language plugin, by their keys; changed in place.</param>
|
||||
public static void AlignInformalVariants(IDictionary<string, string> content)
|
||||
{
|
||||
foreach (var key in content.Keys.ToList())
|
||||
{
|
||||
if (I18NAddressVariant.TryGetFormalKey(key, out var formalKey) && content.TryGetValue(formalKey, out var formalText))
|
||||
content[key] = formalText;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the section of the system prompt about the form of address.
|
||||
/// </summary>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user