npm install localize-with-spreadsheet-2
- Preserve line breaks from the Google Sheets
- Uses newer version of
google-spreadsheet
which in turn supports the Google Sheets v4 API
Requires:
- API key (https://theoephraim.github.io/node-google-spreadsheet/#/getting-started/authentication?id=api-key)
- Spreadsheet key
- Sheet name filter
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
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]')
- The script will preserve everything that is above the tags: < !-- AUTO-GENERATED --> or // AUTO-GENERATED