This is an API for transforming Phrase projects and Google Spreadsheets into i18next translation data. The endpoints are:
Returns un-cached translations for the given Phrase project.
Returns permanently cached translations for the given Phrase project for
each unique value of :version
.
Redirects to the dashboard for the given Phrase project.
-
:sheetId
is the ID of the spreadsheet, which you can find in its URL between/d/
and/edit
:https://docs.google.com/spreadsheets/d/:sheetID/edit ⬆-----⬆ this part
-
sheet
filters the translations by one or more worksheet indices and/or titles. Multiple values are respected. Examples:?sheet=1
will match only the second worksheet (the first is index 0)?sheet=Generic+forms
will match only the worksheet titled "Generic forms"?sheet=*forms
will match all worksheets that end in "forms"?sheet=1&sheet=2
will get the 2nd and 3rd worksheets?sheet=!*wip*
will match worksheets that do not contain "wip"
Worksheets are expected to have a "key" column followed by one or more language code columns. The name of the key column isn't significant, but for consistency it should be "String" or "Key".
All of the rest of the columns should be named with IETF language
tags, e.g. en
for English,
es
for Spanish, zh
for Chinese, or tl
for Tagalog. For instance:
String | en | es |
---|---|---|
hello | Hi | Hola |
goodbye | Bye | Adiós |
The first ("key") column may be empty, in which case the English translation will be used as the key.
-
Copy
.env.template
to.env
and fill in the required environment variables. -
Run
npm run dev
to start the development server, which restarts whenever you modify source files (orpackage.json
) using nodemon. -
Open
https://localhost:8001/google/:sheetId
with a public Google spreadsheet's id in place of:sheetId
, and watch what happens in the console.
This service can be deployed pretty much anywhere, but we're deploying it on Heroku for now. You'll need to set following environment variables ("config vars" in Heroku):
GOOGLE_API_KEY
(required) is your Google API key.