Catalog npm
Back to packageRELEASE DETAILS

1.2.7

npm

20scoops-localizer

Localizer is a script for retrieve locales data on google sheet and save to file for using in application.

Published16 Feb 2021
Direct dependencies15
Transitive dependenciesNot calculated

README

Current package documentation

Localizer

Localizer is a script for retrieve locales data on google sheet and save to file for using in application.

How it looks like?

Usage

yarn add 20scoops-localizer
yarn localizer

Step 1

Create file called localizer.js. The only minimum config required is url which is google sheet url you want to retrieve locales data from

module.exports = {
  url:
    'https://docs.google.com/spreadsheets/d/1RzakawKOAo9JLz-MTkM9Iz5dqYmC6XvqcVmegUCos48/edit#gid=0',
}

and run script

yarn localizer

Step 2

Prompt will asked your secret key (What is secret key and how to retrieve it?).

It only ask for the first time when you install this package.

Step 3

Prompt will asked to visit the url and provide token (What is token and how to retrieve it?). This is for retrieve private google sheet.

It only ask for the first time when you install this package.

Step 4

That's it. If you provide correctly, it will show where files are saved.

Don't worry if you provide incorrectly, just run again and you can provide correct token / secret.

How to retrieve secret key and token

Secret key

It's secret key of OAuth google. You can get it from slack channel #general-dev. I'll pin on there under "20scoops-localizer" section or you can ask in the channel.

Token

Token is authorization key so that script can retrieve data on private google sheet on behalf of you. You can get this token by following the url the script provide in Step 3 on Usage section or run script localizer --get-refresh-token

Continuous Integration (CI)

How to use on Continuous Integration (CI)

Set up LOCALIZER_CREDENTIAL_TOKEN and LOCALIZER_REFRESH_TOKEN on environtment

You can get refresh token from Option

Example for Github Actions

- name: Localizer
  env:
    LOCALIZER_CREDENTIAL_TOKEN: ${{ secrets.LOCALIZER_CREDENTIAL_TOKEN }}
    LOCALIZER_REFRESH_TOKEN: ${{ secrets.LOCALIZER_REFRESH_TOKEN }}
  run: yarn localizer

How localizer read/export locales from google sheet

Example google sheet

Can divide the headers by merge row of sheet.

google-sheet-example

Example output for esm format

//en.js

const en = {
  translation: {
    btnLogin: 'Login',
    username: 'Username',
    password: 'Password',
    welcome: 'Welcome',
    hello: 'Hello',
    morning: 'Morning',
  },
}
export default en
//de.js

const de = {
  translation: {
    btnLogin: 'Anmeldung',
    username: 'Nutzername',
    password: 'Passwort',
    welcome: 'herzlich willkommen',
    hello: 'Hallo',
    morning: 'Guten morgen',
  },
}
export default de

Example output for commonjs format

//en.js

module.exports = {
  btnLogin: 'Login',
  username: 'Username',
  password: 'Password',
  welcome: 'Welcome',
  hello: 'Hello',
  morning: 'Morning',
}
//de.js

module.exports = {
  btnLogin: 'Anmeldung',
  username: 'Nutzername',
  password: 'Passwort',
  welcome: 'herzlich willkommen',
  hello: 'Hallo',
  morning: 'Guten morgen',
}

localizer assume first row is for headline. it will start retrieve data after the first row.

In addition, the Localizer has the following rules

  • The first column is the key for developer.
  • The second to last column is the name of the language that is exported. There will be a key to each file.

Options

OptionsParametersDescriptionDefault value
--clientID=$clientIDCredential client_id in google credential.If not organization 20Scoops-CNX. Can input new client_id from google credential.client_id of 20Scoops CNX
--projectID=$projectIDCredential project_id in google credential.If not organization 20Scoops-CNX. Can input new project_id from google credential.project_id of 20Scoops CNX
--localizerFile=$localizerFileLocation file localizerIf file localizer isn't stay in root project can input location file./localizer.js
--get-refresh-tokenN/AGet refresh token for run with CI.N/A

Config

You can config script by creating localizer.js on your root project.

Example

module.exports = {
  dest: './locales',
  filename: {
    en: 'en.js',
    de: 'de.js',
  },
  url:
    'https://docs.google.com/spreadsheets/d/1RzakawKOAo9JLz-MTkM9Iz5dqYmC6XvqcVmegUCos48/edit#gid=0',
  ignoreColumns: ['th', 'description'],
  sheetName: '',
  module: 'esm',
}
KeyValueRequiredDefault
urlGoogle Sheets URL.YesN/A
destLocation of local file storage.No./locales/
filenameFilename will corresponds to language.No{en: 'en.js',de: 'de.js',}
ignoreColumnsScript will ignore columns is selectNo[]
sheetNameScript will retrieve locales from specified sheet name via this config.No''
moduleType of output esm, commonjs, android-xml or ios-strings.Noesm

** If sheetName more than 1. You can set follow sheetName:['sheet1', 'sheet2']

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 15

Native requirements
15 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
chalk
Environment
{
  "local_name": "chalk",
  "alias": false,
  "peer_metadata": null
}
^2.4.2runtime
fs-extra
Environment
{
  "local_name": "fs-extra",
  "alias": false,
  "peer_metadata": null
}
^8.1.0runtime
googleapis
Environment
{
  "local_name": "googleapis",
  "alias": false,
  "peer_metadata": null
}
^44.0.0runtime
stringify-object
Environment
{
  "local_name": "stringify-object",
  "alias": false,
  "peer_metadata": null
}
^3.3.0runtime
strings-file
Environment
{
  "local_name": "strings-file",
  "alias": false,
  "peer_metadata": null
}
^0.0.5runtime
xmlbuilder
Environment
{
  "local_name": "xmlbuilder",
  "alias": false,
  "peer_metadata": null
}
^13.0.2runtime
yargs
Environment
{
  "local_name": "yargs",
  "alias": false,
  "peer_metadata": null
}
^14.2.0runtime
eslint
Environment
{
  "local_name": "eslint",
  "alias": false,
  "peer_metadata": null
}
^6.6.0development
eslint-config-prettier
Environment
{
  "local_name": "eslint-config-prettier",
  "alias": false,
  "peer_metadata": null
}
^6.5.0development
eslint-config-standard
Environment
{
  "local_name": "eslint-config-standard",
  "alias": false,
  "peer_metadata": null
}
^14.1.0development
eslint-plugin-import
Environment
{
  "local_name": "eslint-plugin-import",
  "alias": false,
  "peer_metadata": null
}
^2.18.2development
eslint-plugin-node
Environment
{
  "local_name": "eslint-plugin-node",
  "alias": false,
  "peer_metadata": null
}
^10.0.0development
eslint-plugin-promise
Environment
{
  "local_name": "eslint-plugin-promise",
  "alias": false,
  "peer_metadata": null
}
^4.2.1development
eslint-plugin-standard
Environment
{
  "local_name": "eslint-plugin-standard",
  "alias": false,
  "peer_metadata": null
}
^4.0.1development
prettier
Environment
{
  "local_name": "prettier",
  "alias": false,
  "peer_metadata": null
}
^1.19.1development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-JCrZM3YOYkP+QajZkK4NpxgzrYSqPG4DKgnBy+61ULvEd95EcDG1xuZ2GxGFmv97EVUNiFh6XlOJb1q+q+99HA==",
  "shasum": "d3d06f59c55fde7ca1477c65b2ee8924b010050b",
  "tarball": "https://registry.npmjs.org/20scoops-localizer/-/20scoops-localizer-1.2.7.tgz",
  "fileCount": 17,
  "unpackedSize": 105072,
  "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgK4PrCRA9TVsSAnZWagAA0IUP/iIgYv3izhsxucEh5oAR\na6brNmwpPYGhlHTD3bFoKOFmNSFyBZXR/iSGwcpKVeXhC30DmM9FdcpzzvFO\n05XZF2YT0UFrcdNmQ2R0hfW8awKmgkIqNpFicSlGCNSdvOpqnS+4LxUZSCO3\nTiGRFrGbws0lQOAltC4KHK31IktzXJsk63mm66RnEkwTTg2AmwH/IUzBGT6c\n/0JNNaJlQVr8/QJr/8WML1UQz6LSjFRfW4fyPPX8pxwJ+I8x4w+xkpWOJp4N\nsA2h2DlCEY9ebAW3StNBBePA8k111xKCRDA4L+YOlBJO8gU6wt3DXoA7Mv4J\n70JGAhkSLi698lN4Acx+pTDj3oADhsEyq9MrpQ9VtcH23LzCA5j0rR0Z1Atv\nabs2mgtIlS7pIcVLtHEoEHqKtv2gY831zfmamav7kEBveh6mrI03B191fThC\nYE0oWpjxRkyStGOeS4ohodoZRY7As+oQ4gdU0QRZZU3vU4qYGg0xBY1jdSCH\nWiZ4CnlirjK3JJ0HyuS+shRKvFgNWvYz+fxJKGtIdVPwhPP5WR8xwdM3d27F\nHj6jkYWduvxUYoPDtvOqyGcd8DJUvYQJXmXMQTw1+sGFcBB7NxRW4k644o4c\n/GnUfzMNr1iFpz6nUwEGmeLtfETK43f/pGQtj3m7ESPZ49adtD1HnB1BV4Fv\n2rEq\r\n=tzMt\r\n-----END PGP SIGNATURE-----\r\n",
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEQCIG+nSgf2h/iWcHCKPmZKDOSUL55cu0PUOuJJ9X6lIyM9AiAvQwRrld/YNMsvVt12I4owQNit4unOlh4Bk64CQ44dbw=="
    }
  ]
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:57 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:3bd149369b0c7528d3d95070b4a8d116a2ddadb17de2af753b77233944c38df3

Other collected versions

2.0.124 Apr2.0.024 Apr1.2.812 Jul1.2.629 Nov1.2.526 Nov1.2.425 NovView all collected versions →