tx3bas commited on
Commit
7d1c3fa
·
verified ·
1 Parent(s): 5f15cf1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -17
app.py CHANGED
@@ -112,22 +112,8 @@ def main(Texto, source_lang, target_lang):
112
  # Realizar la traducción
113
  translated_text = translate_text(source_lang, target_lang, Texto)
114
 
115
- # Escapar comillas para evitar errores en el JavaScript
116
- translated_text_escaped = translated_text.replace('"', '"')
117
-
118
- # Generar salida HTML con botón de copia
119
- html_output = f"""
120
- <div style="white-space: pre-wrap;">
121
- {translated_text}
122
- <button class="lg secondary svelte-cmf5ev"
123
- style="font-size: small; padding: 2px; color: #808080ba; border: none; margin-left: 5px;"
124
- onclick='navigator.clipboard.writeText("{translated_text_escaped}").then(() => alert("Texto copiado al portapapeles"))'>
125
-
126
- </button>
127
- </div>
128
- """
129
-
130
- return html_output
131
 
132
  iface = gr.Interface(
133
  fn=main,
@@ -136,7 +122,7 @@ iface = gr.Interface(
136
  gr.Dropdown(lang_list, label="Idioma origen", value="Automático"),
137
  gr.Dropdown(lang_list, label="Idioma destino", value="Español")
138
  ],
139
- outputs="html",
140
  title="<div style='margin:0 auto;text-align:center'><div style='margin:0 auto;text-align:center'><img style='width:100px;display: inline-table;margin-bottom:-10px' src='https://artxeweb.com/media/files/idioma.jpg'><p>Traducción sin límites</p></div>",
141
  description="<p style='margin-bottom:10px;text-align:center;background: #ffffff; padding: 8px; border-radius: 8px; border-width: 1px; border: solid 1px #e5e7eb;'>Ingresa el texto que deseas traducir, selecciona el idioma origen (o deja 'Automático') y el idioma de destino. ¡No hay límites!</p>",
142
  article="<div style='margin-top:10px'><p style='text-align: center !important; background: #ffffff; padding: 5px 30px; border-radius: 8px; border-width: 1px; border: solid 1px #e5e7eb; width: fit-content; margin: auto;'>Desarrollada por <a style='text-decoration: none !important; color: #e12a31 !important;' title='Artxe Web' href='https://artxeweb.com'>© Artxe Web</a></p></div>"
 
112
  # Realizar la traducción
113
  translated_text = translate_text(source_lang, target_lang, Texto)
114
 
115
+ # Devolver el texto plano sin formato HTML renderizado
116
+ return translated_text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
  iface = gr.Interface(
119
  fn=main,
 
122
  gr.Dropdown(lang_list, label="Idioma origen", value="Automático"),
123
  gr.Dropdown(lang_list, label="Idioma destino", value="Español")
124
  ],
125
+ outputs="text", # Cambiado de "html" a "text" para mostrar texto plano
126
  title="<div style='margin:0 auto;text-align:center'><div style='margin:0 auto;text-align:center'><img style='width:100px;display: inline-table;margin-bottom:-10px' src='https://artxeweb.com/media/files/idioma.jpg'><p>Traducción sin límites</p></div>",
127
  description="<p style='margin-bottom:10px;text-align:center;background: #ffffff; padding: 8px; border-radius: 8px; border-width: 1px; border: solid 1px #e5e7eb;'>Ingresa el texto que deseas traducir, selecciona el idioma origen (o deja 'Automático') y el idioma de destino. ¡No hay límites!</p>",
128
  article="<div style='margin-top:10px'><p style='text-align: center !important; background: #ffffff; padding: 5px 30px; border-radius: 8px; border-width: 1px; border: solid 1px #e5e7eb; width: fit-content; margin: auto;'>Desarrollada por <a style='text-decoration: none !important; color: #e12a31 !important;' title='Artxe Web' href='https://artxeweb.com'>© Artxe Web</a></p></div>"