quasalang icon indicating copy to clipboard operation
quasalang copied to clipboard

Google Translate with Google Sheets

Open LiamKarlMitchell opened this issue 2 years ago • 5 comments

Found a nice way to populate the translations quickly using Google Translate via Google Sheets.

Language codes can be found here. https://cloud.google.com/translate/docs/languages

The formula entered into a new Locale column you want to add to your translations sheet.

=GOOGLETRANSLATE(cell with text, “source language”, “target language”)
such as
=GOOGLETRANSLATE($B2,"en","fr")

Then you can drag the formula down all the cells.

image

Then you can File | Download | CSV and replace the one in your project file and generate as normal.

LiamKarlMitchell avatar Dec 04 '21 16:12 LiamKarlMitchell

@LiamKarlMitchell wow thanks that's really helpful! I'm definitely gonna use this on Fudget 2. @fabform thanks! I wonder if there's a way we can use this to automatically download the sheet as CSV (with an npm package or something) ...

dannyconnell avatar Jan 10 '22 14:01 dannyconnell

@LiamKarlMitchell we can also use an if statement to check that the source field is not blank before we do the translation, so that we can avoid errors on blank lines (if, for example we're separating different sections with blank lines and comments, as below):

Screenshot 2022-01-10 at 14 10 23

dannyconnell avatar Jan 10 '22 14:01 dannyconnell

Yeah, google sheet works great, just need to automate download from it. If better translations are made then can just update them later, of course be careful who writes in your translations if it is going in v-html etc.

LiamKarlMitchell avatar Jan 11 '22 08:01 LiamKarlMitchell

Thanks for your Quasar videos btw @dannyconnell

LiamKarlMitchell avatar Jan 13 '22 13:01 LiamKarlMitchell

Formula with check for not empty. =IF($B3<>"",GOOGLETRANSLATE($B3, "en", "fr"),"")

Also you can download CSV automagically.

I was considering extending the watcher command to have an optional -gs googlesheeturl that it could poll for difference. As an HTTP HEAD request doesn't show any kind of e-tag or version identifier sadly can only do a checksum to a temp file and over-write previous translation.csv if different as the watcher check looks at a timestamp.

If you make a google sheet public for anyone with url can view.

URL to download a google sheet looks like. https://docs.google.com/spreadsheets/d/{DocumentId}/gviz/tq?tqx=out:csv&sheet={SheetName}

Or rather than extending for now, maybe I'de just make an accompanying script that does the download and re-executes quasalang seems to work well enough.

LiamKarlMitchell avatar May 01 '22 16:05 LiamKarlMitchell