Skip to content

Instantly share code, notes, and snippets.



Created Jan 21, 2021
What would you like to do?
Google Translate for Stata
cap prog drop gtrans
prog def gtrans , rclass
syntax anything
qui {
local theText = subinstr("`anything'"," ","%20",.) // HTML for whitespace
import delimited using ///
"`theText'&target=en&key=XXX" /// replace XXX with API key
, clear
keep v1
keep if regexm(v1,"translated")
replace v1 = substr(v1,strpos(v1,":")+1,.)
replace v1 = subinstr(v1,`"""',"",.)
replace v1 = trim(v1)
local theNewText = v1 in 1
return local text = "`theNewText'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment