Disabling Auto Interface Translation in Drupal 9

Sonvir
Sonvir Choudhary
blog image
Drupal

On a recent Drupal project, we ran into a scenario where we had a centralized marketing team managing content for a large global company. The team was primarily English-speaking and was responsible for the content across multiple countries and languages. As the new multilingual sites were being built out, the addition of new languages automatically caused the system to import interface translations which translated the administration interface. Unfortunately, this made the site extremely hard to navigate for the teams responsible for working with it, and we needed to find a way to disable the auto interface translation.

As we searched around, we were not able to find good documentation for this “feature” and how to alter it, so we decided to put it together!

The Problem

When we add a language to the Drupal system it starts a batch process that adds the interface translation for that language. Out of the box, Drupal doesn’t provide any interface to disable this.

Updating Translations in Drupal backend

The Solution

Interface Translation is a part of locale Drupal’s core module. Which adds the interface translation. When we install the locale module it creates a locale.settings.yml which contains the below settings.

cache_strings: true
translate_english: false
javascript:
  directory: languages
translation:
  use_source: remote_and_local
  default_filename: '%project-%version.%language.po'
  default_server_pattern: 'https://ftp.drupal.org/files/translations/%core/%project/%project-%version.%language.po'
  overwrite_customized: false
  overwrite_not_customized: true
  update_interval_days: 0
  path: ''
  import_enabled: true

Screenshot of adding a language in the Drupal interface

local.module file contains the below code which gets called when the Add language form is submitted.

if (\Drupal::config('locale.settings')->get('translation.import_enabled')) {
    // Download and import translations for the newly added language.
    $batch = locale_translation_batch_update_build([], [$langcode], $options);
    batch_set($batch);
  }

Check - locale_form_language_admin_add_form_alter_submit function.

If we set import_enabled to false then interface translation will be disabled and it’ll simply add the new language.

After a bit of digging, we had good news that it was a simple configuration file change to update this. If you found this information helpful, or need help with a development challenge you and/or your team are facing we would love to hear from you!

Drupal