i18n-spreadsheet-generator
v1.1.3
Published
MagLoft i18n Google Spreadsheet Generator
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.
sheetIdthe Google Sheet ID (from the url in the browser), example:1qGpJl7qm0igCM4GE4IRlQf9eyStfSNZ7e26pYN0adRA.GOOGLE_SERVICE_ACCOUNT_EMAILyour google service account, example:[email protected]GOOGLE_PRIVATE_KEYis 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 parsedsheetIndexthe Google Sheet Index in the Spreadsheet, example: 0 (first index).enableDefaultLocalizationdefault valuefalse, iftruethe other empty language's text will use English's text.sheetTypethe Google Sheet Type (Type-LanguageorType-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.tswith scriptnpm run test
