Skip to content

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

Notifications You must be signed in to change notification settings

NeverwinterMoon/localize-with-spreadsheet-2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%