Skip to content
Using the v2 Google Translate API to translate a web page in the browser.
HTML JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
img
index.html
readme.md
script.js

readme.md

Google Translate API Demo

A proof-of-concept for using Google Translate in the browser (without caching translations) for web content.

GIF of translate demo

Motivation

The City of Chicago is developing a web content translation strategy to comply with the 2015 language access ordinance. This repo demonstrates the viability of the Google Translate v2 API for translating web content. This demo uses the AutoML v2 API for simplicity; a city-wide deployment would likely use the new NMT v3 API for greater accuracy.

Next Steps

This demo is a minimal proof-of-concept for web-based translation. A more complete script would scan the DOM for text objects, make one API call containing all text to be translated, and replace all text objects. To ensure translation quality, the script could also send the source text for translation rather than the browser text, as the browser text can be translated back and forth between different languages and get a bit jumbled along the way.

A Note on the Google Translate API

Google does not make it easy to get an API key. I recommend following the Google codelabs tutorial, specifically steps 2-5, to get started.

You can’t perform that action at this time.