localize-with-spreadsheet-2

3.0.0 • Public • Published

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
  • Uses newer version of google-spreadsheet which in turn supports the Google Sheets v4 API

Example

Requires:

Create a file update-localization.js

const Localize = require('localize-with-spreadsheet-2')

Localize.fromGoogleSpreadsheet('[api-key]', '[spreadsheet-key]', '*')
  .then(localizer => {
    localizer.setKeyCol('KEY') // name of the column containing the translation key

    Array.from(['en', 'de']).forEach(language => localizer.save(
      `project-name/resource/${language}.lproj/Localizable.strings`,
      { valueCol: language, format: 'ios' } // format can also be 'android' or 'json'
    ))
  })

Run it with node update-localization.js

Advanced

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

Localize.fromGoogleSpreadsheet('[api-key]', '[spreadsheet-key]', '*')
Localize.fromGoogleSpreadsheet('[api-key]', '[spreadsheet-key]', '[mobile-app]')

Notes

  • The script will preserve everything that is above the tags: < !-- AUTO-GENERATED --> or // AUTO-GENERATED

Readme

Keywords

none

Package Sidebar

Install

npm i localize-with-spreadsheet-2

Weekly Downloads

141

Version

3.0.0

License

none

Unpacked Size

20.9 kB

Total Files

8

Last publish

Collaborators

  • neverwintermoon