How to Setup Directus Content Translations
In this blog, our team at Lunarbyte will show you how to setup content translations in Directus. The objectives are:
Create an Article collection with title and body
Create a translations collection for the articles collection
Create a new collection called articles. There is nothing special about this collection. You can use the collection default options and save.
Within this collection create a new field and select “Translations” from the dropdown.
After clicking the translations option, rename the translations table to “article_translations”. This is our naming convention preference to keep translation tables associated to each collection. Click “Auto Generate”
At this point, you should have three different data models listed under your “Data Model” tab. This includes: articles, languages, and articles_translations. We will use articles_translations to create any fields that need translations.
Now lets create some fields that we would like to be translated within the articles. In this case we will setup a standard field for title and another standard field for body.
At this point we are ready to create an article with fields that can be translated. Head over to the collections tab -> articles and create a new article.
In the new article interface you will see the Article Translations relationship at the bottom. You can click on each language you would like to provide a translation for.
After clicking on a specific language, you will see a drawer popup. This will allow you to input the specific language for those fields. You will need to provide values for each specific language you want to support.
You are done with translations. Now you can enable the permissions for accessing articles and articles_translations via the API. You can adjust permissions based on your needs.