From e9102f7e1e65ad1ed3c1990c28d5e4021b3d8d27 Mon Sep 17 00:00:00 2001 From: Miguel Date: Mon, 16 Jun 2025 21:24:03 +0200 Subject: [PATCH] =?UTF-8?q?Agregadas=20opciones=20de=20traducci=C3=B3n=20a?= =?UTF-8?q?=20portugu=C3=A9s=20en=20la=20aplicaci=C3=B3n,=20incluyendo=20a?= =?UTF-8?q?justes=20en=20el=20men=C3=BA=20y=20la=20l=C3=B3gica=20de=20proc?= =?UTF-8?q?esamiento=20de=20texto.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.xaml.cs | 13 ++++++++----- ContextMenuWindow.xaml.cs | 2 ++ Program.cs | 3 +++ README.md | 9 ++++++++- gtpask.cs | 10 ++++++++-- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/App.xaml.cs b/App.xaml.cs index 252205f..30e78f8 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -20,16 +20,15 @@ namespace GTPCorrgir bool CorreccionFinalizada = false; Stopwatch stopwatch = new Stopwatch(); private notificacion notificationWindow; - private readonly int TimeoutSeconds = 60; // Timeout máximo para esperar la respuesta + private readonly int TimeoutSeconds = 60; private CancellationTokenSource _cancellationTokenSource; + private Window _mainWindow; KeyboardHelper pasteLogic = new KeyboardHelper(); - private Window _mainWindow; - protected override async void OnStartup(StartupEventArgs e) { - ShutdownMode = ShutdownMode.OnExplicitShutdown; // Añade esta línea + ShutdownMode = ShutdownMode.OnExplicitShutdown; base.OnStartup(e); _cancellationTokenSource = new CancellationTokenSource(); @@ -84,6 +83,7 @@ namespace GTPCorrgir case Opciones.modoDeUso.Traducir_a_Espanol: case Opciones.modoDeUso.Traducir_a_Ingles: case Opciones.modoDeUso.Traducir_a_Italiano: + case Opciones.modoDeUso.Traducir_a_Portugues: await HandleTextCorrection(); return; } @@ -107,6 +107,9 @@ namespace GTPCorrgir } GTP.TextoACorregir = await ClipboardHelper.GetText(); + stopwatch.Start(); + ShowCustomNotification("Espera", $"Procesando texto con {Opciones.Instance.nombreDeLLM()}..."); + IniciarCronometro(); await ProcessCorreccionWithTimeout(); } @@ -152,7 +155,7 @@ namespace GTPCorrgir if (Opciones.Instance.modo == Opciones.modoDeUso.Corregir || Opciones.Instance.modo == Opciones.modoDeUso.Ortografia || Opciones.Instance.modo == Opciones.modoDeUso.Traducir_a_Espanol || Opciones.Instance.modo == Opciones.modoDeUso.Traducir_a_Ingles || - Opciones.Instance.modo == Opciones.modoDeUso.Traducir_a_Italiano) + Opciones.Instance.modo == Opciones.modoDeUso.Traducir_a_Italiano || Opciones.Instance.modo == Opciones.modoDeUso.Traducir_a_Portugues) { if (Opciones.Instance.FuncionesOpcionales == Opciones.funcionesOpcionales.MostrarPopUp) { diff --git a/ContextMenuWindow.xaml.cs b/ContextMenuWindow.xaml.cs index 12694b0..4c62e16 100644 --- a/ContextMenuWindow.xaml.cs +++ b/ContextMenuWindow.xaml.cs @@ -43,9 +43,11 @@ namespace GTPCorrgir new MenuOption { DisplayName = "Corregir texto", Value = Opciones.modoDeUso.Corregir }, new MenuOption { DisplayName = "Revisar ortografía", Value = Opciones.modoDeUso.Ortografia }, new MenuOption { DisplayName = "Chat", Value = Opciones.modoDeUso.Chat }, + new MenuOption { DisplayName = "Pregunta-Respuesta", Value = Opciones.modoDeUso.PreguntaRespuesta }, new MenuOption { DisplayName = "Traducir a inglés", Value = Opciones.modoDeUso.Traducir_a_Ingles }, new MenuOption { DisplayName = "Traducir a italiano", Value = Opciones.modoDeUso.Traducir_a_Italiano }, new MenuOption { DisplayName = "Traducir a español", Value = Opciones.modoDeUso.Traducir_a_Espanol }, + new MenuOption { DisplayName = "Traducir a portugués", Value = Opciones.modoDeUso.Traducir_a_Portugues }, new MenuOption { DisplayName = "OCR a texto", Value = Opciones.modoDeUso.OCRaTexto } }; diff --git a/Program.cs b/Program.cs index df1645f..7ed0997 100644 --- a/Program.cs +++ b/Program.cs @@ -33,6 +33,7 @@ namespace GTPCorrgir Traducir_a_Ingles, Traducir_a_Italiano, Traducir_a_Espanol, + Traducir_a_Portugues, OCRaTexto, Menu, } @@ -118,6 +119,8 @@ namespace GTPCorrgir Opciones.Instance.modo = Opciones.modoDeUso.Traducir_a_Italiano; if (arg.Contains("Traducir_a_Espanol")) Opciones.Instance.modo = Opciones.modoDeUso.Traducir_a_Espanol; + if (arg.Contains("Traducir_a_Portugues")) + Opciones.Instance.modo = Opciones.modoDeUso.Traducir_a_Portugues; if (arg.Contains("OCRaTexto")) Opciones.Instance.modo = Opciones.modoDeUso.OCRaTexto; if (arg.Contains("AutoCopy")) diff --git a/README.md b/README.md index 42f5c8b..1d646e7 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,11 @@ Los parametros son: ### Modo de funcionamiento *********************** * `--Chat` : Para crear una mini ventana que permite hacer chat con los modelos sellecionados. -* `--Correccion` (default ) : Correccion desde el portapapeles y hacia el portapapeles \ No newline at end of file +* `--Corregir` (default) : Corrección desde el portapapeles y hacia el portapapeles +* `--Ortografia` : Revisar ortografía del texto en el portapapeles +* `--Traducir_a_Ingles` : Traducir texto al inglés +* `--Traducir_a_Italiano` : Traducir texto al italiano +* `--Traducir_a_Espanol` : Traducir texto al español +* `--Traducir_a_Portugues` : Traducir texto al portugués +* `--OCRaTexto` : Capturar pantalla y convertir imagen a texto +* `--Menu` : Mostrar menú de selección de opciones \ No newline at end of file diff --git a/gtpask.cs b/gtpask.cs index b84f888..042b38d 100644 --- a/gtpask.cs +++ b/gtpask.cs @@ -189,7 +189,8 @@ namespace GTPCorrgir { return Opciones.Instance.modo == Opciones.modoDeUso.Traducir_a_Ingles || Opciones.Instance.modo == Opciones.modoDeUso.Traducir_a_Italiano || - Opciones.Instance.modo == Opciones.modoDeUso.Traducir_a_Espanol; + Opciones.Instance.modo == Opciones.modoDeUso.Traducir_a_Espanol || + Opciones.Instance.modo == Opciones.modoDeUso.Traducir_a_Portugues; } private string ObtenerIdiomaObjetivo() @@ -199,6 +200,7 @@ namespace GTPCorrgir Opciones.modoDeUso.Traducir_a_Ingles => _languageMap["en"], Opciones.modoDeUso.Traducir_a_Italiano => _languageMap["it"], Opciones.modoDeUso.Traducir_a_Espanol => _languageMap["es"], + Opciones.modoDeUso.Traducir_a_Portugues => _languageMap["pt"], _ => throw new ArgumentException("Modo de traducción no válido") }; } @@ -262,6 +264,7 @@ namespace GTPCorrgir throw new ApplicationException("Error al extraer el texto corregido de la respuesta JSON"); } + TextoCorregido = System.Text.RegularExpressions.Regex.Replace(TextoCorregido, @"\*\*(.*?)\*\*", "$1"); TextoCorregido = _markdownProcessor.RemoveTechnicalTermMarkers_IgnoreCase(TextoCorregido).Trim('"'); TextoCorregido = _markdownProcessor.RemoveDoubleBrackets(TextoCorregido); } @@ -307,7 +310,7 @@ namespace GTPCorrgir "You are an engineer working in industrial automation. Your task is to review texts and rewrite them in a simple and concise manner. If you find words enclosed in double brackets [[like this]], preserve them exactly as they appear without any modifications. For all other technical terms, write them normally without adding any brackets or special formatting. Preserve any existing markdown language if present. Please rewrite the following text in " + IdiomaDetectado + " and respond in the following JSON format: { \"Rewritten_text\": \"Your text here\" }. Important: Do not add any new brackets to words that aren't already enclosed in double brackets.", Opciones.modoDeUso.Ortografia => - "Please check the following text for spelling errors and provide the corrected version. Do not change the meaning or structure of the sentences. If you find words enclosed in double brackets [[like this]], preserve them exactly as they appear. For all other words, only correct spelling mistakes while preserving technical terms and any markdown language if present. Please write in " + IdiomaDetectado + " and respond in the following JSON format: { \"Rewritten_text\": \"Your text here\" }.", + "Please check the following text for spelling errors and provide the corrected version. Do not change the meaning or structure of the sentences. If you find words enclosed in double brackets [[like this]], preserve them exactly as they appear. For all other words, only correct spelling mistakes while preserving technical terms. Preserve any existing markdown language if present, but do not introduce new markdown styling (such as bold or italics) for emphasis unless it was part of the original input. Please write in " + IdiomaDetectado + " and respond in the following JSON format: { \"Rewritten_text\": \"Your text here\" }.", _ => "You are an engineer working specialized in industrial automation. If the question contains words in double brackets [[like this]], preserve them exactly as they appear. Please answer the following question in " + IdiomaDetectado + " and respond in the following JSON format: { \"Reply_text\": \"Your text here\" }." }; @@ -331,6 +334,9 @@ namespace GTPCorrgir Opciones.modoDeUso.Traducir_a_Espanol => $"Please check the following text for spelling errors and provide the corrected version tranlated to Spanish. Do not change the meaning or structure of the sentences. Only correct any spelling mistakes you find on: \"{texto}\"", + Opciones.modoDeUso.Traducir_a_Portugues => + $"Please check the following text for spelling errors and provide the corrected version tranlated to Portuguese. Do not change the meaning or structure of the sentences. Only correct any spelling mistakes you find on: \"{texto}\"", + _ => texto };