i18n-spreadsheet-generator
v1.1.3
Published
MagLoft i18n Google Spreadsheet Generator
Downloads
9
Readme
i18n Spreadsheet Generator
Generate Localizations
- Create the Google Spreadshee and list the localizations keywords & languages, example: https://docs.google.com/spreadsheets/d/1qGpJl7qm0igCM4GE4IRlQf9eyStfSNZ7e26pYN0adRA/edit?usp=sharing.
- Call function
generateLocalization(config: Config)
to update the JSON data.
Environment Setup
A Config
args needs to be passed on function generateLocalization.
sheetId
the Google Sheet ID (from the url in the browser), example:1qGpJl7qm0igCM4GE4IRlQf9eyStfSNZ7e26pYN0adRA
.GOOGLE_SERVICE_ACCOUNT_EMAIL
your google service account, example:[email protected]
GOOGLE_PRIVATE_KEY
is the Service Account private key (starting with-----BEGIN PRIVATE KEY...
). Make sure to wrap the content in double quotes ("
) so that newlines (\n
) are properly parsedsheetIndex
the Google Sheet Index in the Spreadsheet, example: 0 (first index).enableDefaultLocalization
default valuefalse
, iftrue
the other empty language's text will use English's text.sheetType
the Google Sheet Type (Type-Language
orType-Country
) in the Spreadsheet, see in the example Spreadsheet above. There are 2 kinds of the Sheet Type. Generated Results:Type-Language
: { "en": { "SAMPLE_KEY": "TEXT_EN" }, "bg": { "SAMPLE_KEY": "TEXT_BG" } ... }Type-Country
: { "be": { "en": { "SAMPLE_KEY": "TEXT_EN" }, "nl": { "SAMPLE_KEY": "TEXT_BG" }, "fr": { "SAMPLE_KEY": "TEXT_BG" } } ... }
Generate Localizations Test
- Run test example
Generator.test.ts
with scriptnpm run test