vue-google-translation-sheets
v1.0.9
Published
A **free** Package for importing key values from google sheets to the application (for development and can only be used with vue-i18n package)
Downloads
5
Maintainers
Readme
google-translate-for-vue
A free Package for importing key values from google sheets to the application (for development and can only be used with vue-i18n package)
Install
npm install --save vue-google-translation-sheets
Usage
Read all values from google sheets and create separate json for each language
Configuration
Google Api
- head to https://console.developers.google.com/
- create a new project
- Make sure to activate Sheet Api for the project
- Navigate to "Library"
- Search "Google Sheets API" > Click on "Google Sheets API"
- Click "Enable"
- Create a Service Account and credentials
- Navigate to "Credentials"
- Click "Create credentials"
- choose "Service Account key"
- Choose A "New Service Account" in the "Service account" select
- Choose a name. (ie. This is the name that will show up in the Spreadsheet history operations), "Editor" as role and "JSON" for the key type.
- Save the credentials to root folder. (You can choose another name/folder if you want in your application folder)
- Make sure to write down the service account email, you will need it later for the package configuration.
Spreadsheet
- Create a blank/new spreadsheet here https://docs.google.com/spreadsheets/ .
- Share it with the service account email with
Can edit
permission. - Sample spreadhseet
Required configuration
In your .env file (Create .env file in root folder)
# Path to the downloaded service account credentials file (in root folder)
GOOGLE_SERVICE_ACCOUNT_CREDENTIALS = "../../LanguageTransalation-dce184a223e3.json"
# The ID of the spreadsheet that we will be using for translation
SPREADSHEET_ID= "1LlU6SRjPCR1WQ2S2gP4KiHhcDuEoXxgSgmFEx_PiiwI"
#path to store transalation files
PATH = "./src/lang"
# The locales of the application (separated by comma)
LOCALES=en,no,pl,sw
npm script
Add this script to your package.json to pull sheets
"scripts": {
"translate": "node node_modules/vue-google-translation-sheets/index.js"
},
Usage
Run script
This need to be done only once.
$ npm run translate