diff --git a/src/Commands/GenerateCommitMessage.cs b/src/Commands/GenerateCommitMessage.cs
index 3bcf7010..cbf36b71 100644
--- a/src/Commands/GenerateCommitMessage.cs
+++ b/src/Commands/GenerateCommitMessage.cs
@@ -70,12 +70,22 @@ namespace SourceGit.Commands
}
}
+ private static string GetSelectedLanguagePrompt()
+ {
+ var selectedLanguage = Models.OpenAI.SelectedLanguage == "English"
+ ? string.Empty
+ : $"{Environment.NewLine}Always write in {Models.OpenAI.SelectedLanguage}";
+
+ return selectedLanguage;
+ }
+
private string GenerateChangeSummary(Models.Change change)
{
var rs = new GetDiffContent(_repo, new Models.DiffOption(change, false)).ReadToEnd();
var diff = rs.IsSuccess ? rs.StdOut : "unknown change";
+ var selectedLanguagePrompt = GetSelectedLanguagePrompt();
- var rsp = Models.OpenAI.Chat(Models.OpenAI.AnalyzeDiffPrompt, $"Here is the `git diff` output: {diff}", _cancelToken);
+ var rsp = Models.OpenAI.Chat(Models.OpenAI.AnalyzeDiffPrompt + selectedLanguagePrompt, $"Here is the `git diff` output: {diff}", _cancelToken);
if (rsp != null && rsp.Choices.Count > 0)
return rsp.Choices[0].Message.Content;
@@ -84,7 +94,8 @@ namespace SourceGit.Commands
private string GenerateSubject(string summary)
{
- var rsp = Models.OpenAI.Chat(Models.OpenAI.GenerateSubjectPrompt, $"Here are the summaries changes:\n{summary}", _cancelToken);
+ var selectedLanguagePrompt = GetSelectedLanguagePrompt();
+ var rsp = Models.OpenAI.Chat(Models.OpenAI.GenerateSubjectPrompt + selectedLanguagePrompt, $"Here are the summaries changes:\n{summary}", _cancelToken);
if (rsp != null && rsp.Choices.Count > 0)
return rsp.Choices[0].Message.Content;
diff --git a/src/Models/OpenAI.cs b/src/Models/OpenAI.cs
index b1bb9465..e04682db 100644
--- a/src/Models/OpenAI.cs
+++ b/src/Models/OpenAI.cs
@@ -94,6 +94,12 @@ namespace SourceGit.Models
set;
}
+ public static string SelectedLanguage
+ {
+ get;
+ set;
+ }
+
public static string AnalyzeDiffPrompt
{
get;
diff --git a/src/Resources/Icons.axaml b/src/Resources/Icons.axaml
index 1a84597e..e280fba4 100644
--- a/src/Resources/Icons.axaml
+++ b/src/Resources/Icons.axaml
@@ -61,6 +61,7 @@
M412 66C326 132 271 233 271 347c0 17 1 34 4 50-41-48-98-79-162-83a444 444 0 00-46 196c0 207 142 382 337 439h2c19 0 34 15 34 33 0 11-6 21-14 26l1 14C183 973 0 763 0 511 0 272 166 70 393 7A35 35 0 01414 0c19 0 34 15 34 33a33 33 0 01-36 33zm200 893c86-66 141-168 141-282 0-17-1-34-4-50 41 48 98 79 162 83a444 444 0 0046-196c0-207-142-382-337-439h-2a33 33 0 01-34-33c0-11 6-21 14-26L596 0C841 51 1024 261 1024 513c0 239-166 441-393 504A35 35 0 01610 1024a33 33 0 01-34-33 33 33 0 0136-33zM512 704a192 192 0 110-384 192 192 0 010 384z
M512 64A447 447 0 0064 512c0 248 200 448 448 448s448-200 448-448S760 64 512 64zM218 295h31c54 0 105 19 145 55 13 12 13 31 3 43a35 35 0 01-22 10 36 36 0 01-21-7 155 155 0 00-103-39h-31a32 32 0 01-31-31c0-18 13-31 30-31zm31 433h-31a32 32 0 01-31-31c0-16 13-31 31-31h31A154 154 0 00403 512 217 217 0 01620 295h75l-93-67a33 33 0 01-7-43 33 33 0 0143-7l205 148-205 148a29 29 0 01-18 6 32 32 0 01-31-31c0-10 4-19 13-25l93-67H620a154 154 0 00-154 154c0 122-97 220-217 220zm390 118a29 29 0 01-18 6 32 32 0 01-31-31c0-10 4-19 13-25l93-67h-75c-52 0-103-19-143-54-12-12-13-31-1-43a30 30 0 0142-3 151 151 0 00102 39h75L602 599a33 33 0 01-7-43 33 33 0 0143-7l205 148-203 151z
M922 39H102A65 65 0 0039 106v609a65 65 0 0063 68h94v168a34 34 0 0019 31 30 30 0 0012 3 30 30 0 0022-10l182-192H922a65 65 0 0063-68V106A65 65 0 00922 39zM288 378h479a34 34 0 010 68H288a34 34 0 010-68zm0-135h479a34 34 0 010 68H288a34 34 0 010-68zm0 270h310a34 34 0 010 68H288a34 34 0 010-68z
+ M480-120q-74.31 0-140-28.42-65.69-28.43-114.42-77.16-48.73-48.73-77.16-114.42Q120-405.69 120-480q0-74.54 28.42-140.12 28.43-65.57 77.16-114.3 48.73-48.73 114.42-77.16Q405.69-840 480-840q74.54 0 140.12 28.42 65.57 28.43 114.3 77.16 48.73 48.73 77.16 114.3Q840-554.54 840-480q0 74.31-28.42 140-28.43 65.69-77.16 114.42-48.73 48.73-114.3 77.16Q554.54-120 480-120Zm0-39.69q35.23-45.23 58.08-88.85 22.84-43.61 37.15-97.61H384.77q15.85 57.07 37.92 100.69 22.08 43.61 57.31 85.77Zm-50.92-6q-28-33-51.12-81.58-23.11-48.58-34.42-98.88H190.15q34.39 74.61 97.5 122.38 63.12 47.77 141.43 58.08Zm101.84 0q78.31-10.31 141.43-58.08 63.11-47.77 97.5-122.38H616.46q-15.15 51.07-38.27 99.65-23.11 48.58-47.27 80.81ZM173.85-386.15h161.38q-4.54-24.62-6.42-47.97-1.89-23.34-1.89-45.88 0-22.54 1.89-45.88 1.88-23.35 6.42-47.97H173.85q-6.54 20.77-10.2 45.27Q160-504.08 160-480t3.65 48.58q3.66 24.5 10.2 45.27Zm201.38 0h209.54q4.54-24.62 6.42-47.2 1.89-22.57 1.89-46.65t-1.89-46.65q-1.88-22.58-6.42-47.2H375.23q-4.54 24.62-6.42 47.2-1.89 22.57-1.89 46.65t1.89 46.65q1.88 22.58 6.42 47.2Zm249.54 0h161.38q6.54-20.77 10.2-45.27Q800-455.92 800-480t-3.65-48.58q-3.66-24.5-10.2-45.27H624.77q4.54 24.62 6.42 47.97 1.89 23.34 1.89 45.88 0 22.54-1.89 45.88-1.88 23.35-6.42 47.97Zm-8.31-227.7h153.39Q734.69-690 673.5-736.23q-61.19-46.23-142.58-58.85 28 36.85 50.35 84.27 22.35 47.43 35.19 96.96Zm-231.69 0h190.46q-15.85-56.3-39.08-101.84-23.23-45.54-56.15-84.62-32.92 39.08-56.15 84.62-23.23 45.54-39.08 101.84Zm-194.62 0h153.39q12.84-49.53 35.19-96.96 22.35-47.42 50.35-84.27-82.16 12.62-142.96 59.23-60.81 46.62-95.97 122Z
M875 117H149C109 117 75 151 75 192v640c0 41 34 75 75 75h725c41 0 75-34 75-75V192c0-41-34-75-75-75zM139 832V192c0-6 4-11 11-11h331v661H149c-6 0-11-4-11-11zm747 0c0 6-4 11-11 11H544v-661H875c6 0 11 4 11 11v640z
M875 117H149C109 117 75 151 75 192v640c0 41 34 75 75 75h725c41 0 75-34 75-75V192c0-41-34-75-75-75zm-725 64h725c6 0 11 4 11 11v288h-747V192c0-6 4-11 11-11zm725 661H149c-6 0-11-4-11-11V544h747V832c0 6-4 11-11 11z
M40 9 15 23 15 31 9 28 9 20 34 5 24 0 0 14 0 34 25 48 25 28 49 14zM26 29 26 48 49 34 49 15z
diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml
index 2726aec2..4b571648 100644
--- a/src/Resources/Locales/en_US.axaml
+++ b/src/Resources/Locales/en_US.axaml
@@ -19,6 +19,7 @@
Track Branch:
Tracking remote branch
OpenAI Assistant
+ Language used to generate commit message
Use OpenAI to generate commit message
Patch
Error
diff --git a/src/Resources/Locales/pt_BR.axaml b/src/Resources/Locales/pt_BR.axaml
index 45d3e3f9..d5eac91d 100644
--- a/src/Resources/Locales/pt_BR.axaml
+++ b/src/Resources/Locales/pt_BR.axaml
@@ -20,6 +20,9 @@
Branch Existente
O que Checar:
Adicionar Worktree
+ Assistente do OpenAI
+ Idioma usado a gerar a mensagem de commit
+ Usar OpenAI para gerar mensagem de commit
Erros levantados e se recusa a aplicar o patch
Erro
Semelhante a 'erro', mas mostra mais
diff --git a/src/ViewModels/Preference.cs b/src/ViewModels/Preference.cs
index 72667f54..13f28f17 100644
--- a/src/ViewModels/Preference.cs
+++ b/src/ViewModels/Preference.cs
@@ -316,6 +316,19 @@ namespace SourceGit.ViewModels
}
}
+ public string SelectedLanguage
+ {
+ get => Models.OpenAI.SelectedLanguage;
+ set
+ {
+ if (value != Models.OpenAI.SelectedLanguage)
+ {
+ Models.OpenAI.SelectedLanguage = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
public string OpenAIAnalyzeDiffPrompt
{
get => Models.OpenAI.AnalyzeDiffPrompt;
@@ -591,6 +604,9 @@ namespace SourceGit.ViewModels
- Be as concise as possible, keep the message under 50 characters.
""";
}
+
+ if (string.IsNullOrEmpty(Models.OpenAI.SelectedLanguage))
+ Models.OpenAI.SelectedLanguage = "English";
}
private RepositoryNode FindNodeRecursive(string id, List collection)
diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs
index 6fcbedd9..282f4cc4 100644
--- a/src/ViewModels/WorkingCopy.cs
+++ b/src/ViewModels/WorkingCopy.cs
@@ -8,6 +8,7 @@ using Avalonia.Platform.Storage;
using Avalonia.Threading;
using CommunityToolkit.Mvvm.ComponentModel;
+using SourceGit.Models;
namespace SourceGit.ViewModels
{
@@ -1147,6 +1148,37 @@ namespace SourceGit.ViewModels
return menu;
}
+ public ContextMenu CreateContextMenuForSelectedLanguage()
+ {
+ var menu = new ContextMenu();
+ var selectedLanguage = string.IsNullOrEmpty(Preference.Instance.SelectedLanguage)
+ ? "English"
+ : Preference.Instance.SelectedLanguage;
+
+ foreach (var locale in Locale.Supported)
+ {
+ var language = locale.Name;
+
+ var item = new MenuItem
+ {
+ Header = language,
+ Icon = selectedLanguage.Equals(language, StringComparison.OrdinalIgnoreCase)
+ ? App.CreateMenuIcon("Icons.Check")
+ : null
+ };
+
+ item.Click += (_, e) =>
+ {
+ Preference.Instance.SelectedLanguage = language;
+ e.Handled = true;
+ };
+
+ menu.Items.Add(item);
+ }
+
+ return menu;
+ }
+
public ContextMenu CreateContextMenuForCommitMessages()
{
var menu = new ContextMenu();
diff --git a/src/Views/WorkingCopy.axaml b/src/Views/WorkingCopy.axaml
index 3d080fc6..0ef3c033 100644
--- a/src/Views/WorkingCopy.axaml
+++ b/src/Views/WorkingCopy.axaml
@@ -55,7 +55,7 @@
Classes="icon_button"
Width="26" Height="14"
Padding="0"
- ToolTip.Tip="{DynamicResource Text.WorkingCopy.Unstaged.StageAll}"
+ ToolTip.Tip="{DynamicResource Text.WorkingCopy.Unstaged.StageAll}"
Command="{Binding StageAll}">
@@ -99,7 +99,7 @@
-
@@ -135,7 +135,7 @@
-
+
@@ -165,7 +165,7 @@
-
+
@@ -185,7 +185,7 @@
-
+
-
+
+
+
+
-
-
+