Skip to content

Commit

Permalink
traducao
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel marques do Nascimento committed Nov 14, 2024
1 parent 2b7f4a9 commit 1a4da50
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<link rel="stylesheet" href="css/menu.css" />
<link rel="stylesheet" href="css/animation.css" />
</head>
<style></style>

<body>
<style>
#console {
Expand Down
3 changes: 3 additions & 0 deletions js/Premium.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// const contein_elem_premium = document.createElement("div");


7 changes: 7 additions & 0 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,13 @@ window.onload = function () {
if (data["theme"] == "black") {
autoThemeTime(0, true);
}


if (paragrafo_style.display == "none") {

console.log("paragraph: ", paragrafo_style.display)
}

};

document.addEventListener("DOMContentLoaded", function () {
Expand Down
31 changes: 31 additions & 0 deletions js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,34 @@ export function console_log(text, view = false) {
console.log(text);
}
}


export async function traduzirTexto(texto, idiomaAlvo) {
const url = "https://libretranslate.com/translate";

const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
},
body: JSON.stringify({
q: texto,
source: "auto", // Detecta automaticamente o idioma de entrada
target: idiomaAlvo
}),
});

const data = await response.json();
if (data.error) {
console.error("Erro na tradução:", data.error);
return null;
}

return data.translatedText;
}

// Exemplo de uso
traduzirTexto("Olá, como vai?", "en")
.then(traducao => console.log(traducao))
.catch(error => console.error("Erro:", error));

0 comments on commit 1a4da50

Please sign in to comment.