npm install --save gatsby-source-transifex
First, you need a way to pass environment variables to the build process, so secrets and other secured data aren't committed to source control. We recommend using [dotenv
][dotenv] which will then expose environment variables. [Read more about dotenv and using environment variables here][envvars]. Then we can use these environment variables and configure our plugin.
// In your gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-source-transifex`,
options: {
organization: `your_organization`,
project: `your_project`,
source_lang_code: `en`, // default lang
locales: [`de`,`sv`], // array of all translated lang
auth: `${process.env.TRANSIFEX_USER}:${process.env.TRANSIFEX_TOKEN}`,
},
},
],
}
You might query for all of resources:
{
allTransifexTranslationField {
nodes {
id
}
}
allTransifexResourceField {
nodes {
id
}
}
}
{
transifexTranslationField(id: {eq: "transifex-{insert-your-resource-id}-{insert-locale}"}) {
id
json
}
}
{
transifexResourceField(id: {eq: "transifex-{insert-your-resource-id}"}) {
id
json
}
}
{
allTransifexTranslationField(filter: { node_locale: { eq: "de" } }) {
nodes {
id
}
}
}