The most unloved thing in the frontend is to write localization files, this library comes to your aid, which will help you
$ npm i translation-service-google-sheets -D
create file translate.js
import translate from 'translation-service-google-sheets';
// Initialize the sheet - doc ID is the long id in the sheets URL
// You can pass array of id
const docs = ["sdfasdfTRXX2y9KJt1Q0GEN1qnjpi13o"];
// Google api key
const apiToken = process.env.GOOGLE_PRIVATE_KEY;
// base path form root folder
const basePath = "static";
const config = {
docs,
apiToken,
basePath,
};
translate(config);
node translate.js
Perfect!
"easy": "to use",
"free": "example"
"prebuild": "node translate.js",
Setup Instructions
-
Follow steps above to set up project and enable sheets API
-
Create an API key for your project
-
Navigate to the credentials section of the google developer console
-
Click blue "+ CREATE CREDENTIALS" and select "API key" option
-
Copy the API key
OPTIONAL
- click "Restrict key" on popup to set up restrictions
- Click "API restrictions" > Restrict Key"
- Check the "Google Sheets API" checkbox
- Click "Save"