Descarga el plugin de WordPress o copia el código para cualquier otro sistema. Necesitas una API Key (crédela en el panel de administración si tienes acceso).
Instálalo en tu WordPress y configura la API Key en Ajustes > Lang Translate API.
Descargar lang-translate-api.zipURL directa: https://lang.amberdev.online/download/plugin
Un botón flotante ES | EN que traduce la página al instante y recuerda el idioma elegido. Funciona en cualquier sitio (HTML, WordPress, etc.).
1. Pega esta línea antes de </body> (sustituye TU_API_KEY por tu credencial):
<script src="https://lang.amberdev.online/static/widget.js" data-lang-api-key="TU_API_KEY" data-lang-default="es"></script>
Opcionales: data-lang-api-url="https://lang.amberdev.online" si usas otro dominio, data-lang-content="main" para traducir solo <main>, data-lang-labels="ES|EN" para las etiquetas.
Pega tu credencial y pulsa el botón para comprobar que la API responde correctamente.
Copia y pega en tu proyecto. Sustituye TU_API_KEY por tu credencial.
const LANG_API_URL = 'https://lang.amberdev.online';
const LANG_API_KEY = 'TU_API_KEY'; // Créala en lang.amberdev.online (admin)
async function traducirTexto(texto, idiomaDestino = 'es', idiomaOrigen = 'auto') {
const res = await fetch(LANG_API_URL + '/translate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Api-Key': LANG_API_KEY
},
body: JSON.stringify({
text: texto,
target_lang: idiomaDestino,
source_lang: idiomaOrigen
})
});
if (!res.ok) throw new Error(await res.text());
const data = await res.json();
return data.translated_text;
}
// Uso: traducirTexto('Hello world', 'es').then(console.log);
Copia y pega en tu proyecto PHP. Sustituye TU_API_KEY por tu credencial.
<?php
function lang_traducir($texto, $destino = 'es', $origen = 'auto') {
$url = 'https://lang.amberdev.online/translate';
$key = 'TU_API_KEY'; // Créala en lang.amberdev.online (admin)
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
'text' => $texto,
'target_lang' => $destino,
'source_lang' => $origen
]),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Api-Key: ' . $key
],
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30
]);
$res = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($code !== 200) return $texto;
$data = json_decode($res, true);
return $data['translated_text'] ?? $texto;
}
// Uso: echo lang_traducir('Hello world', 'es');
?>
curl -X POST https://lang.amberdev.online/translate \
-H "Content-Type: application/json" \
-H "X-Api-Key: TU_API_KEY" \
-d '{"text":"Hello world","target_lang":"es","source_lang":"auto"}'