Translations
Canvas supports symmetric translations: every translation shares the same component tree, and only the translatable inputs of each component instance differ per language. This guide walks through enabling translations on Drupal CMS.
Enable translation support
Section titled “Enable translation support”- Enable the core translation modules:
- Language module
- Content Translation module (to translate Canvas Pages)
- Configuration Translation module (to translate global regions and content templates)
- Configure the languages available on the site at
/admin/config/regional/language. - Make the Canvas “Page” entity type translatable at
/admin/config/regional/content-language:- In Custom language settings, click “Page”.
- Under the Page collapsible, check “Page”.
- Under the translatable fields settings, ensure “Components” is checked.
- Save changes.
You will also need a module that provides a UI for translating Canvas content, because the UI provided by the core Content Translation module does not currently support translating Canvas content. You can use either TMGMT or the experimental Canvas Translate module.
Translating with TMGMT
Section titled “Translating with TMGMT”- Download it:
composer require 'drupal/tmgmt:^1.18' - Enable the Translation Management Core module.
- Enable the Content Entity Source module (to translate Canvas Pages).
- Enable the Config Entity Source module (to translate global regions and content templates).
This example proceeds with TMGMT’s built-in user translation module. Consider adopting a different translation provider, since the Drupal user translation capabilities are very basic.
- Enable TMGMT’s “Drupal user” (tmgmt_local) module.
- Configure the user’s translation skills at the bottom of the user edit
form (for example,
/user/1/edit). This is required for TMGMT to allow using Drupal user translation. - Request translations manually at
/admin/tmgmt/sources. - Configure the provider at
/admin/tmgmt/translators. - Optionally, set up continuous translation at
/admin/tmgmt/jobsso that a new translation is requested every time changes are made.
Translating a page
Section titled “Translating a page”- Create a page in the Canvas editor and add a component with translatable content (for example, a Text component).
- Publish the page.
- Go to
/admin/tmgmt/sources. - Locate and select the Page source.
- Choose the source language and target language.
- Select the page and request a translation.
- Assign the job to a user with matching translation skills and submit it to the translation provider.
- Open the translation task at
/translateand fill in the translated content. - Save the translation and click Save as completed.
- Review the finished translation at
/admin/tmgmtand click Save as completed to accept it. - Return to the Canvas editor for the page.
- Use the language switcher at the top of the editor to verify that the translation exists. A check mark appears next to the translated language.
- Translations can also be deleted from the language switcher if needed.
Translating a content template
Section titled “Translating a content template”- Create an article.
- Navigate to Content Templates in the Canvas editor.
- Open the content template and add a component (for example, a Text component).
- Publish the changes to the content template.
- Go to
/admin/tmgmt/sources. - Locate and select the Content Template source.
- Choose the source language and target language.
- Select the content template and request a translation.
- Assign the job to a user with matching translation skills and submit it to the translation provider.
- Open the translation task at
/translateand fill in the translated content. - Save the translation and click Save as completed.
- Review the finished translation at
/admin/tmgmtand click Save as completed to accept it. - Return to the Canvas editor for the content template.
- Use the language switcher at the top of the editor to verify that the translation exists. A check mark appears next to the translated language.
- Translations can also be deleted from the language switcher if needed.
Translating with Canvas Translate (experimental)
Section titled “Translating with Canvas Translate (experimental)”Canvas Translate provides a translation UI inside the Canvas editor and does not require TMGMT.
- Download it:
composer require 'drupal/canvas_translate:^1.0@alpha' - Enable the Canvas Translate module.
- Clear caches.
- Canvas Translate now appears in the left sidebar in Canvas.