4bh1nav / localize-with-spreadsheet-2

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert a Google Spreadsheet to a localization file. Version 2

Installation

npm install localize-with-spreadsheet-2

Differences in version 2 (only major ones listed)

  • Preserve line breaks from the Google Sheets

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

const Localize = require('localize-with-spreadsheet')
const transformer = Localize.fromGoogleSpreadsheet('0Aq6WlQdq71FydDZlaWdmMEUtc2tUb1k2cHRBS2hzd2c', '*')
const properties = (value) => {
  return { valueCol: value, format: 'android' } // similarly, for iOS: { valueCol: value, format: 'ios' } 
}

transformer.setKeyCol('KEY')
transformer.save('values/strings.xml', properties('NL'));
transformer.save('values-fr/strings.xml', properties('FR'));

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

About

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


Languages

Language:JavaScript 100.0%