This add-on allows you to quickly translate selected document text between several languages and reinsert it into the document. This was built as a sample add-on for Google Docs. You can find the source code here: https://developers.google.com/apps-script/quickstart/docs