Giter VIP home page Giter VIP logo

localize-with-spreadsheet's Introduction

Convert a Google Spreadsheet to a localization file

Installation

npm install localize-with-spreadsheet

Example

Given a Google Spreadsheet like this:
Spreadsheet example

The tool fetch the spreadsheet and write the result to a file in the Android or iOS format:

Result android Result iOS

Create a file update-localization.js

var Localize = require("localize-with-spreadsheet");
var transformer = Localize.fromGoogleSpreadsheet("0Aq6WlQdq71FydDZlaWdmMEUtc2tUb1k2cHRBS2hzd2c", '*');
transformer.setKeyCol('KEY');

transformer.save("values/strings.xml", { valueCol: "NL", format: "android" });
transformer.save("values-fr/strings.xml", { valueCol: "FR", format: "android" });

transformer.save("nl.lproj/Localizable.strings", { valueCol: "NL", format: "ios" });
transformer.save("fr.lproj/Localizable.strings", { valueCol: "FR", format: "ios" });

Run it with

node update-localization.js

Advanced

You can filter the worksheets to include with the second parameter of 'fromGoogleSpreadsheet' Ex:

Localize.fromGoogleSpreadsheet("<Key>", '*');
Localize.fromGoogleSpreadsheet("<Key>", ['HomeScreen, 'ContactScreen']);
Localize.fromGoogleSpreadsheet("<Key>", [0, 2]);

Notes

  • The script will preserve everything that is above the tags: < !-- AUTO-GENERATED --> or // AUTO-GENERATED
  • Your spreadsheet should be "Published" for this to work
  • You need to have git installed for the installation

localize-with-spreadsheet's People

Contributors

xvrh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

localize-with-spreadsheet's Issues

Empty Cell

It would be great if there was an option to skip generating strings on empty cells.
This would be useful when you have strings that are for system use or maybe strings that does not need translation.

Unexpected close tag

I get the following, and yes my spreadsheet is published.

Error while fetching the Spreadsheet (Error: Unexpected close tag
Line: 1253
Column: 9
Char: >)
WARNING! Check that your spreadsheet is "Published" in "File > Publish to the web..."
Unhandled rejected promise: Error: Unexpected close tag
Line: 1253
Column: 9
Char: >
at error (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/node_modules/sax/lib/sax.js:667:10)
at strictFail (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/node_modules/sax/lib/sax.js:693:7)
at closeTag (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/node_modules/sax/lib/sax.js:887:9)
at Object.write (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/node_modules/sax/lib/sax.js:1449:13)
at Parser.exports.Parser.Parser.parseString (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/lib/xml2js.js:508:31)
at Parser.parseString (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/lib/xml2js.js:7:59)
at Request._callback (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/index.js:193:12)
at Request.self.callback (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/request/request.js:187:22)
at Request.emit (events.js:98:17)
at Request. (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/request/request.js:1044:10)

TypeError: Cannot read property '#' of undefined
at /Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/index.js:44:22
at Parser. (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/index.js:186:6)
at Parser.emit (events.js:95:17)
at Object.onclosetag (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/lib/xml2js.js:447:26)
at emit (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/node_modules/sax/lib/sax.js:640:35)
at emitNode (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/node_modules/sax/lib/sax.js:645:5)
at closeTag (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/node_modules/sax/lib/sax.js:905:7)
at Object.write (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/node_modules/sax/lib/sax.js:1449:13)
at Parser.exports.Parser.Parser.parseString (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/lib/xml2js.js:508:31)
at Parser.parseString (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/node_modules/xml2js/lib/xml2js.js:7:59)
at Request._callback (/Users/ivanstashak/dev/localization/node_modules/localize-with-spreadsheet/node_modules/google-spreadsheet/index.js:193:12)

Is there any way to change what % is changed into?

In my project I use a lot of String.formats() with multiple %s, so i would like to avoid those being changed into %1$.

Is there a way for me to change this behavior by editing one of the project files?

node-google-spreadsheets is no longer hosted on xavierha's github

During installation, this error message appears:

npm ERR! Error while executing:
npm ERR! C:\Program Files\Git\cmd\git.EXE ls-remote -h -t git://github.com/xavierha/node-google-spreadsheets.git
npm ERR!
npm ERR! fatal: remote error:
npm ERR!   Repository not found.
npm ERR!
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\drain\AppData\Roaming\npm-cache\_logs\2018-12-28T15_06_52_216Z-debug.log

This is due to the fact that node-google-spreadsheets is no longer hosted on xavierha's github.

Gen Localizable.strings to Excel

Hi @XavierHa
Thank for your tool convert Excel to Localizable.strings.
But, do you know tool convert Localizable.strings to Excel?
If you know, please show me.
thank you!

Unhandled rejection promise

saving values/strings.xml
making request -- GET - https://spreadsheets.google.com/feeds/worksheets/0Av3IECowXxw9dGN1bnc4aEZxYzF2N3ZORmVpZHdqM2c/public/values
saving values-es/strings.xml
Unhandled rejected promise: Error: 140735097291136:error:0607907F:digital envelope routines:EVP_PKEY_get1_RSA:expecting an rsa key:../deps/openssl/openssl/crypto/evp/p_lib.c:288:

at CleartextStream._pusher (tls.js:656:24)
at SlabBuffer.use (tls.js:199:18)
at CleartextStream.CryptoStream._push (tls.js:483:33)
at SecurePair.cycle (tls.js:880:20)
at EncryptedStream.CryptoStream.write (tls.js:267:13)
at Socket.ondata (stream.js:38:26)
at Socket.EventEmitter.emit (events.js:96:17)
at TCP.onread (net.js:397:14)

Unhandled rejected promise: Error: 140735097291136:error:0607907F:digital envelope routines:EVP_PKEY_get1_RSA:expecting an rsa key:../deps/openssl/openssl/crypto/evp/p_lib.c:288:

at CleartextStream._pusher (tls.js:656:24)
at SlabBuffer.use (tls.js:199:18)
at CleartextStream.CryptoStream._push (tls.js:483:33)
at SecurePair.cycle (tls.js:880:20)
at EncryptedStream.CryptoStream.write (tls.js:267:13)
at Socket.ondata (stream.js:38:26)
at Socket.EventEmitter.emit (events.js:96:17)
at TCP.onread (net.js:397:14)

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.