Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including google-sheets-translate with all npm packages installed. Try it out:

var googleSheetsTranslate = require("google-sheets-translate")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

google-sheets-translate v0.2.6

Maintain your translations in Google Sheets and fetch them into JSON files


Maintain your translations in Google Sheets and fetch them into JSON files - ready to be used other translation libraries like Globalize

Getting started

Steps to get started with Google documents. See more verbose version in related project:

  • Register app in Google Developers Console
  • Enable Google Drive API
  • Create Service account under Credentials (get P12 key)
  • Convert P12 key into PEM format
  • Collect the service email account
  • Create Google Sheets -document
  • Share the document to service email address

NOTE: Authentication is required - link based sharing is not currently supported.

Example document:

Bonus: Use GOOGLETRANSLATE for creating initial translations

Example code:

var fs = require('fs');

var GoogleSheetsTranslate = require('google-sheets-translate');

var gtranslator = new GoogleSheetsTranslate({
  documentId: 'your-document-id',
  serviceEmail: '',
  serviceKey: fs.readFileSync('./your-service.pem').toString()

var output;
.then(function(translations) {
  translations.forEach(function(translation, locale) {
    // In this example we're writing files in Globalize compatible format
    output = {};
    output[locale] = translation;
      'messages/' + locale + '.json',
      JSON.stringify(output, null, 2)
.catch(function(err) {
  console.warn('Failed to generate translations:', err);

Example output:

  "en": {
    "translation": "Translation",
    "dog-house": "Doghouse",
    "sister": "Sister"
  "fi": {
    "translation": "Käännös",
    "dog-house": "Koirankoppi",
    "sister": "Sisko"


new GoogleSheetsTranslate(opts)

Create an instance from the client. All the options are required.

  • @param {Object} opts All the options
  • @param {String} id Sheets document id
  • @param {String} opts.serviceEmail Service email address
  • @param {String} opts.serviceKey Service .PEM key contents


Retrieve the translations from the sheet. All the options are optional.

  • @param {Object} opts All the options
  • @param {String} opts.sheetOrdinal Sheet ordinal to process. Defaults to 0 (first sheet)
  • @param {String} opts.sheetName Sheet name to process. If not provided, uses sheetOrdinal
  • @param {String} opts.range Range where the translations are. Defaults to whole document (first row contains the header)


Module is MIT -licensed


Module is backed by Nordcloud

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free