Skip to content

Create a localization file in Android or iOS format from a Google Spreadsheet

Notifications You must be signed in to change notification settings

tomzr/localize-with-spreadsheet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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(/credentials/, /spreadsheetId/, '*');
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
  • From Google Sheets API v4 update, account credentials needs to be passed. They must contain private key and client email in the form of JSON object.

Tests

Tests are localized under tests/ directory. Some of them are written in nodeunit (package is already deprecated). To run nodeunit tests execute:

node tests/all.js

There are some already migrated to the jest tool. To run them execute:

npm test or yarn test

About

Create a localization file in Android or iOS format from a Google Spreadsheet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%