Update app.py
Browse files
app.py
CHANGED
|
@@ -66,19 +66,36 @@ def translate_text(lang, text):
|
|
| 66 |
translated_text = ''.join(translated_chunks)
|
| 67 |
return translated_text
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
with gr.Blocks(analytics_enabled=False) as app:
|
| 70 |
-
gr.HTML("<h3><center>🌐 Traducción sin
|
| 71 |
Source = gr.Textbox(label="Introduce el texto a traducir")
|
| 72 |
Language = gr.Dropdown(lang_list, label="Idioma", default="Español")
|
| 73 |
Translate = gr.Button("Traducir 💬")
|
| 74 |
gr.HTML("<br>")
|
| 75 |
Result = gr.Textbox(label="Resultado")
|
| 76 |
|
|
|
|
|
|
|
|
|
|
| 77 |
Translate.click(
|
| 78 |
translate_text,
|
| 79 |
inputs=[Language, Source],
|
| 80 |
outputs=[Result],
|
| 81 |
api_name="translate",
|
| 82 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
gr.HTML("<p style='text-align:center !important;'>Desarrollada por <a style='text-decoration:none !important;color:#e12a31 !important;' href='https://artxeweb.com'>© Artxe Web</a></p>")
|
| 84 |
app.launch(inline=True)
|
|
|
|
| 66 |
translated_text = ''.join(translated_chunks)
|
| 67 |
return translated_text
|
| 68 |
|
| 69 |
+
def copy_to_clipboard(text):
|
| 70 |
+
# Esta función se ejecutará al hacer clic en el botón de copiar
|
| 71 |
+
st.write(f"Texto copiado al portapapeles: {text}")
|
| 72 |
+
st.write("¡Ahora puedes pegar el texto donde lo necesites!")
|
| 73 |
+
st.text(text)
|
| 74 |
+
|
| 75 |
with gr.Blocks(analytics_enabled=False) as app:
|
| 76 |
+
gr.HTML("<h3><center>🌐 Traducción sin límites<h3><center>")
|
| 77 |
Source = gr.Textbox(label="Introduce el texto a traducir")
|
| 78 |
Language = gr.Dropdown(lang_list, label="Idioma", default="Español")
|
| 79 |
Translate = gr.Button("Traducir 💬")
|
| 80 |
gr.HTML("<br>")
|
| 81 |
Result = gr.Textbox(label="Resultado")
|
| 82 |
|
| 83 |
+
# Agregar un botón de copia al resultado
|
| 84 |
+
Copy = gr.Button("Copiar 📋")
|
| 85 |
+
|
| 86 |
Translate.click(
|
| 87 |
translate_text,
|
| 88 |
inputs=[Language, Source],
|
| 89 |
outputs=[Result],
|
| 90 |
api_name="translate",
|
| 91 |
)
|
| 92 |
+
|
| 93 |
+
# Configurar la acción del botón de copiar
|
| 94 |
+
Copy.click(
|
| 95 |
+
copy_to_clipboard,
|
| 96 |
+
inputs=[Result],
|
| 97 |
+
outputs=[],
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
gr.HTML("<p style='text-align:center !important;'>Desarrollada por <a style='text-decoration:none !important;color:#e12a31 !important;' href='https://artxeweb.com'>© Artxe Web</a></p>")
|
| 101 |
app.launch(inline=True)
|