faberNovel / ad_localize

ADLocalize is a simple way to manage your localization files. Supported wording sources : CSVs and Google Sheets. Localization file generation available for iOS, Android, JSON (i18next), YAML and Java properties
https://rubygems.org/gems/ad_localize
MIT License
24 stars 8 forks source link

Support multiple sheets. #38

Closed XanderZhu closed 4 years ago

XanderZhu commented 4 years ago

I have multiple localisation sheets in one spreadsheet (one sheet per feature). So, it will be convenient to generate localisation files from all sheets of my spreadsheet by calling bundle exec ad_localize -k <your-spreadsheet-drive-key>. But now this command generate localisation files only for the first sheet.

sjcqs commented 4 years ago

@jvigne What do you think about adding a parameter --export-all-sheets ?

For now the only workaround is:

  1. Get every sheet id manually
  2. Create a script: (pseudo-code)
    for sheet_id in sheet_ids do
    bundle exec ad_localize -k <your-spreadsheet-drive-key> -s sheet_id
    done
sjcqs commented 4 years ago

After digging, using Spreadsheet API to list available sheets inside a file requires authentication.

ADLocalize user will have to create a project on the Google Cloud Console, enable Sheet API and provide the client_secret.json when using ad_localize. (similary to the way this PR works: https://github.com/applidium/ad_localize/pull/32)

jvigne commented 4 years ago

@XanderZhu can you precise if you use the option -a with a google service account or if you just use the option -k ? Also, do you generate the wording for a specific set of platforms ?

XanderZhu commented 4 years ago

@jvigne, at the moment I'm using -k option, but it isn't a problem to switch -a option using.

sjcqs commented 4 years ago

@XanderZhu You should be able to export all sheets from one spreadsheet.

From the README.md

Export wording from a private google spreadsheet using a Google Cloud Service Account. Create a GCloud Service Account: Go to Google Cloud Console Either create a new project or use an existing one (when using Firebase, a GCloud project is created) Go to IAM & Admin / Service Account and create a new service account. Store the created client-secret.json (in a password manager for example) Enable Google Drive API for the projet Go to API / Library and enable the Drive API there. Add the service account to a spreadsheet. In IAM & Admin / Service Account, the service account's email is listed. Invite it to the spreadsheet to export.

$ export GCLOUD_CLIENT_SECRET=$(cat <client-secret.json>)
$ bundle exec ad_localize -k <your-spreadsheet-drive-key> -a

Fetch and export all sheets from a google spreadsheet. (requires a Google Cloud Service Account) The Google Service Account's projet needs to have Google Spreadsheet API enabled.

$ export GCLOUD_CLIENT_SECRET=$(cat <client-secret.json>)
$ bundle exec ad_localize -k <your-spreadsheet-drive-key> -e

Explanation

You need to use a Google Cloud Service Account because adlocalize will use the Google Spreadsheet API to fetch and download individual sheets.

jvigne commented 4 years ago

@XanderZhu starting from version 4.0.0 the option -a is not required to use Google Cloud Service Account as mention in the CHANGELOG. If you use it you will have an error.

To fix your call to ad_localize just remove the -a but let the environment variable.