This app showcases how to build a custom language picker interface while leveraging Google's translation service behind the scenes.
file:// protocol.The app follows a zero-backend, client-side only philosophy aligned with the umabotools project standards:
#google_translate_element) and controls it programmatically.addEventListener pattern (no inline event handlers) for CSP compliance.function googleTranslateElementInit() {
new google.translate.TranslateElement({
pageLanguage: 'en',
includedLanguages: 'en,fr,es,de',
autoDisplay: false
}, 'google_translate_element');
}
function changeLanguage(langCode) {
// Update button visual state
document.querySelectorAll('.lang-btn').forEach(btn => {
btn.classList.toggle('active', btn.dataset.lang === langCode);
});
// Poll for Google's dropdown element
const poll = setInterval(() => {
const combo = document.querySelector('.goog-te-combo');
if (combo) {
combo.value = langCode;
combo.dispatchEvent(new Event('change'));
localStorage.setItem('demo_lang_pref', langCode);
clearInterval(poll);
}
}, 100);
}
Why Polling? Google's translate widget loads asynchronously. The polling mechanism waits for the hidden dropdown (.goog-te-combo) to become available, then programmatically changes its value and triggers the translation.
function checkScriptLoad() {
if (typeof google === 'undefined' || typeof google.translate === 'undefined') {
document.getElementById('error-banner').style.display = 'block';
}
}
Displays a user-friendly error message if:
✅ CSP Compliant:
onclick removed)addEventListener pattern✅ No External Frameworks:
✅ Privacy Transparent:
test_translate.htmlincludedLanguages)This app demonstrates key principles from the umabotools project:
| Principle | Implementation |
|---|---|
| Single-page app | Entire app in one HTML file |
| No backend | Runs via file:// protocol |
| Security-first | No inline handlers, CSP compliant |
| Privacy-conscious | Clear disclosure, minimal data storage |
| Vanilla JS | Zero frameworks or dependencies (except Google API) |
| Accessible | Semantic HTML, keyboard navigation support |
Potential improvements while maintaining the zero-backend philosophy:
includedLanguages)Ctrl+1 for English)This project is licensed under the MIT License.
InnovUmabot | https://innovumabot.com
This tool was vibe-coded with AI with strict human supervision.