younifyd
Menu

Generate Translations

Set Up Translations

POST/utils/translations/generate

Use it in a workflow

  1. Add a step and choose the Directus connector.
  2. Pick the Generate Translations action (under Utilities).
  3. Fill in the fields below, then reference the result from later steps as {{generateTranslations.response.data}}.

Request

Request body

Enter the body as JSON in the step's Body field.

collectionstringrequired

Collection to enable translations on.

fieldsarray<string>required

One or more field names to create on the translations collection.

translationsCollectionstring

Name for the translations collection. Defaults to `{collection}_translations`.

languagesCollectionstring

Name of the languages collection to use or create. Defaults to `languages`.

parentFkFieldstring

Foreign key field on the translations collection pointing to the parent. Defaults to `{collection}_id`.

languageFkFieldstring

Foreign key field on the translations collection pointing to the language. Defaults to `languages_code`.

createLanguagesCollectionboolean

Create the languages collection if it does not exist. Defaults to `true`.

Default true

seedLanguagesboolean

Seed the languages collection with default language entries. Defaults to `true`.

Default true

json
{
  "collection": "articles",
  "fields": [
    "title",
    "body"
  ],
  "translationsCollection": "articles_translations",
  "languagesCollection": "languages",
  "parentFkField": "articles_id",
  "languageFkField": "languages_code",
  "createLanguagesCollection": true,
  "seedLanguages": true
}

Response

Returns 200 with an object. Read it in later steps with {{generateTranslations.response.data.<field>}}.

dataobject
createdboolean

Whether a new translations collection was created.

translationsCollectionstring

Name of the translations collection.

languagesCollectionstring

Name of the languages collection (only present when a new translations collection was created).

fieldsarray<string>

Names of the fields created on the translations collection.

json
{
  "data": {
    "created": false,
    "translationsCollection": "string",
    "languagesCollection": "string",
    "fields": [
      "string"
    ]
  }
}

Need more? See the Directus guide for connection setup and behaviour shared by every action.

Was this page helpful?