Building a Custom, Low-Cost Translator with Google Cloud
The Legal Clinic (TLC) is a Hawaii-based non-profit focused on immigration. They frequently assist individuals with limited English proficiency. Their Squarespace website lacked a translation widget, and they required support for over 10 languages to effectively reach the broad community they serve.
An example of the final product developed for TLC is embedded below. Selecting a language will translate this entire article without reloading the page:
The Case for a Custom Solution
TLC’s budget for translation services was $2,000 per year (approximately $166 per month). Weglot, a standard translation service for Squarespace, costs over $300 per month to support 10 or more languages. Localize, a no-code translation platform, costs over $600 per month for only 6 languages. Both platforms include extra features TLC did not need, and either option substantially exceeded the non-profit’s annual budget.
Additionally, the legacy free Google Translate widget was not a viable option. Google officially deprecated the tool and strictly limits its use to websites focusing on COVID-19 response (although many sites apparently violate this policy without consequence).
To address TLC’s need for a translation widget, a custom solution was developed with the assistance of AI. The architecture consists of two components:
- A browser-side script added to the Squarespace site that reads the page, batches text, and caches previous translations to reduce costs and latency.
- A secure Google Cloud Run backend service that interfaces with the Google Cloud Translation API to translate the text across any of its 180+ supported languages.
Building with AI
Building a reliable translation widget from scratch requires a significant amount of custom programming to correctly read and update a live webpage without breaking it. However, AI coding agents can automate this process quickly and effectively. I used Claude Opus inside the Cursor code editor to architect the custom translation system. From there, Cursor’s automated tools handled the actual coding to generate the widget and backend service.
While AI writes the code quickly enough to compress weeks of work into just a few days, the process still requires rigorous testing to catch errors and ensure the widget works reliably. But even with the time spent on manual and automated testing, the overall speed of building and refining the tool is much faster than writing every line of code by hand.
How It Works
A live webpage consists of code, styling, and content. The custom script first scans through a website’s structure and skips non-text elements and sections marked to ignore. It extracts only the visible text that actually needs conversion.
The script gathers this extracted text and sends it to Google Cloud. Google processes the batch and returns the translated text in real-time. Because webpages contain bold text, italics, hyperlinks, etc., the code carefully maps the translated words back to their exact original locations to keep the site’s layout and functionality fully intact.
Finally, the results are saved locally in the user’s browser for a limited time. If the user switches back to a previous language or revisits a page, the text loads instantly from memory instead of asking Google to translate it again.
The Cost Breakdown
Google Cloud’s pay-as-you-go pricing and generous free tiers make it very cheap to run tools that only a portion of your audience uses. The Google Cloud Translation API provides 500,000 free characters per month, and Cloud Run includes 2 million free requests along with enough processing power to handle the traffic of most users.
The reality is that only a small fraction of TLC’s total site visitors actually require using the translation feature. On any given week, the total gross cost across all Google Cloud services hovers below $5. However, because the low-traffic usage falls entirely within Google’s free tiers, the net cost applied to the invoice is effectively $0.00.
While the custom code includes basic spam protection, adding Google Cloud Armor to block automated attacks is a recommended best practice. This adds about $6 per month ($5 for the base policy, $1 for security rules, and fractions of a penny for traffic).
By comparison, Weglot charges over $300 per month regardless of actual usage. The custom Google Cloud solution operates at $0 to $6 per month and completely avoids the $300~$600 monthly fees of enterprise subscriptions.
Conclusion
Avoiding recurring enterprise software costs saves TLC thousands of dollars annually. These funds can instead be redirected toward their core mission: providing legal services, funding community education, and assisting immigrants in Hawaii.
This project is a practical example of how AI coding tools can help independent software developers build custom software quickly and affordably. Instead of forcing clients into expensive monthly subscriptions for features they don’t need, developers can now build exactly what is required to solve a problem while keeping ongoing costs near zero.
My open source code for this project is available on GitHub. While the code is open source, organizations should engage a professional developer to handle the implementation to ensure it is deployed correctly and securely.