An Interest In:
Web News this Week
- March 21, 2024
- March 20, 2024
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
- March 15, 2024
How to translate HTML for free using google translate.
Introduction
While working on a new feature for my side project eduo instrukcije, I needed to translate HTML to other languages which was challenging to do for free. Google translate api has parameter "format" that when set to "html" ignores all tags and translates only real text, but it's not free. There are couple of reversed engineered google translate apis that are totally free, but none of them had the format option available. Then I found out that you can use Google Translate api inside google sheets, and you can create real apis with google sheets, and I think that's pretty cool.
How to do it?
First open google sheets and open a new app script
Then paste this doGet function
function doGet(e){ var params = e.parameter; var translation = LanguageApp.translate(params.text, params.froml, params.to, {contentType: 'html'}); return ContentService.createTextOutput(translation).setMimeType(ContentService.MimeType.TEXT);}
Then go and deploy your api
Make sure that type is Web app and that everyone has access to it
Testing
Go to your url and add query parameters
And that's it!
Original Link: https://dev.to/jakovglavac/how-to-translate-html-for-free-using-google-translate-2nf
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To