Site Building

10.4. Translating Configuration for Drupal 8, 9, 10, and 11

Goal

Translate the labels on the Recipes view page into Spanish.

Site prerequisites

Steps

Sprout Video

The basic steps for translating any configuration on your site are:

  1. In the Manage administrative menu, navigate to Configuration > Regional and Language > Configuration translation (admin/config/regional/config-translation).
  2. Locate the configuration item that you would like to translate. For example, to translate the site name, you need to find System information. For configuration that is grouped by type (for example, views or date formats), click the List button to list all configuration of that type, and then locate the item you are looking for.
  3. Click Translate for the item you located.
  4. Find a button that will let you add a translation in the desired language, and click this button.
  5. Enter the translation in the form, and save.

Most configuration is fairly straightforward and intuitive to edit in this manner. Views configuration is an exception, because the translation editing form is nothing like the view editing form, and it is complex and hierarchical rather than being a simple form with just a few fields. As an example of how to translate a view, here are the steps to translate the labels in the Recipes view to Spanish:

  1. In the Manage administrative menu, navigate to Configuration > Regional and Language > Configuration translation (admin/config/regional/config-translation).
  2. Click List in the Views row.
  3. Click Translate in the Recipes row.
  4. Click Add in the Spanish row. The page Add Spanish translation for Recipes view appears.
  5. Under Displays > Master Display settings > Recipes default display Options, translate Display title from "Recipes" to "Recetas".
  6. Under Displays > Master display settings > Recipes default display options > Exposed form > Reset options, translate Submit button text from "Apply" to "Applicar". The other buttons and labels in this section do not appear on the Recipes page or block, and do not need to be translated.

    Image
    Translate the Recipes view

  7. Under Displays > Master display settings > Recipes default display options > Filters > (Empty) taxonomy term ID > Find recipes using… Expose, translate Label from "Find recipes using…" to "Encontrar recetas usando…".
  8. Click Save translation.
  9. Navigate to the Recipes page and switch to Spanish using the Language switcher block. Verify that the labels have been translated.

Expand your understanding

  • Translate the block display title in the Recent recipes display settings section of the Recipes view.
  • Translate the page title in the Vendors view.
  • Translate other configuration. Some examples of where to find the translation pages:

    • To translate the site name, navigate in the Manage administrative menu to Configuration > System > Basic site settings > Translate system information (admin/config/system/site-information/translate).
    • To translate the contact form, navigate in the Manage administrative menu to Structure > Contact forms (admin/structure/contact). Click Translate in the dropdown button in the Website feedback row.
    • To translate the name of a menu, navigate in the Manage administrative menu to Structure > Menus (admin/structure/menu). Click Translate in the dropdown button for the menu whose name you want to translate.
    • Menu links within a menu are considered to be content (not configuration); see Section 10.2, “Configuring Content Translation” to enable translation. Once translation is enabled, navigate in the Manage administrative menu to Structure > Menus (admin/structure/menu). Click Edit menu in the dropdown button for the menu whose links you want to translate. Click Translate in the dropdown button for the link you want to translate.
    • To translate field labels on a content type, navigate in the Manage administrative menu to Structure > Content types (admin/structure/types). Click Manage fields in the dropdown button for the content type whose field labels you want to edit. Click Translate in the dropdown button for the field whose label you want to edit.
  • Translate content. See Section 10.3, “Translating Content”.

Drupal User Guide