Code Monkey home page Code Monkey logo

gulp-translations-from-spreadsheet's Introduction

gulp-translations-from-spreadsheet

Build Status

Gulp plugin to generate translations json files for angular application from a google spreadsheet

IMPORTANT: If you do not want to use a service account, google spreadsheet must have no auth public permissions (e.g. Anyone with the link can view) and it should be explicitly published using "File > Publish to the web" menu option in the google spreadsheets GUI. this plugin is based on node-google-spreadsheet

Install

npm install gulp-translations-from-spreadsheet --save-dev

Basic Usage

This code will generate translation json files based on google spreadsheet:

'use strict';

var gulp = require('gulp');
var translations = require('gulp-translations-from-spreadsheet');

gulp.task('translations', function () {
  return translations({
          key: '1cKTLZCglRJkJR_7NGL6vPn1MHdadcLPUOMYjqVKFlB4',
          sheet: 1,
          colCount: 4,
          firstRow: 1,
          private_key_id: 'xxx',
          private_key: '-----BEGIN PRIVATE KEY-----\xxx\n-----END PRIVATE KEY-----\n',
          client_email: '[email protected]',
          client_id: 'xxx.apps.googleusercontent.com',
          ignoreCommentsColumn: false,
          warnOnMissingValues: true,
          errorOnMissingValues: false
      })
    .pipe(gulp.dest('./i18n'));
});

Options

key

Type: String: mandatory

Google spreadsheet key.
Example: https://docs.google.com/spreadsheets/d/1cKTLZCglRJkJR_7NGL6vPn1MHdadcLPUOMYjqVKFlB4/edit?usp=sharing

1cKTLZCglRJkJR_7NGL6vPn1MHdadcLPUOMYjqVKFlB4 is a key here

sheet

Type: Number: optional, default 1

NOTE: Worksheet id, ids start at 1

It is recommended that you DELETE all unused rows and columns in your spreadsheet to optimize load time, and only create additional columns and rows when needed.

The following two options allow you to specify a custom range of columns and rows if required.

firstRow

Type: Number: optional, default 1

NOTE: the index of the first row, start with 1

colCount

Type: Number: optional, default value from spreadsheet

NOTE: the number of valuable columns, it's better to specify this number, otherwise, it could be more than you expect

The following four options are required if you want to use a service account to authenticate (recommended):

private_key_id

Type: String: optional

The Google API private key id to use for authentication.

private_key

Type: String: optional

The Google API private key to use for authentication.

NOTE: You should never commit your private_key into your git repo. Rather you should use an ENV variable.

client_email

Type: String: optional

The Google API email to use for authentication. This account must have read access to the spreadsheet you want to pull the translations from.

client_id

Type: String: optional

The Google API client id to use for authentication.

ignoreCommentsColumn

Type: Boolean: optional, default false

If there is a column with the top cell labelled 'comments', this column will be skipped.

warnOnMissingValues

Type: Boolean: optional, default true

If there is a column lacking a given value, throw a warning in the console.

errorOnMissingValues

Type: Boolean: optional, default false

If there is a column lacking a given value, throw a fatal error and stop the task (recommended).


NOTE: there is link to alternative version of such gulp plugin

gulp-translations-from-spreadsheet's People

Contributors

mikhail-angelov avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

bookeu aquipa

gulp-translations-from-spreadsheet's Issues

Options are broken

languages and keyColumn don't do anything, your code doesn't even reference them.

You need to update documentation to prevent confusion

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.