Drupal Multilingual — Configuration, Content and Interface Translation
In this tutorial, you'll learn how to build multilingual Drupal sites — from enabling languages and configuring content translation to translating interface strings, setting up language switchers, and optimizing multilingual SEO with hreflang tags.
What You'll Learn
- Enabling multilingual modules and adding languages to Drupal
- Configuring language detection methods (URL prefix, domain, browser)
- Translating content with the Content Translation module
- Translating configuration like site name, taxonomy, and views
- Translating the interface with Interface Translation
- Setting up language switchers for multi-language navigation
Why It Matters
Half of the internet's users do not speak English as their first language. A multilingual site reaches wider audiences, improves user experience for non-English speakers, and ranks in multiple language-specific search engines. Drupal has the most robust multilingual capabilities of any major CMS — content, configuration, interface, and URL structure can all be translated. This is why governments, universities, and global enterprises choose Drupal for international sites.
Real-World Use
A European e-commerce company sells products in France, Germany, Italy, and Spain. Their Drupal site serves content in four languages. Each product page has translated title, description, and specifications. The checkout Process is translated to each language. URLs use language prefixes (/fr/produit, /de/produkt). Hreflang tags tell Google which language version to show in each country. The language switcher lets users toggle between versions. Content editors translate products using Drupal's translation UI without developer assistance.
Learning Path
flowchart LR A[SEO] --> B[Multilingual] B --> C[User Roles] C --> D[User Management] D --> E[Security Hardening] E --> F[Custom Modules] F --> G[Hooks]
Multilingual Modules
Drupal core ships with four multilingual modules:
Language — adds languages to the site and configures language detection.
Content Translation — enables translation of content entities (nodes, taxonomy, users, blocks).
Configuration Translation — translates configuration strings (site name, views, field labels).
Interface Translation — translates the Drupal UI and contributed module strings.
# Enable all multilingual modules:
drush en language content_translation config_translation locale
Adding Languages
- Go to Configuration > Regional and language > Languages
- Click "Add language"
- Select a language from the list or search
- Click "Add language"
# Add languages via Drush:
drush language-add fr
drush language-add de
drush language-add es
drush language-add it
# List installed languages:
drush language-info
# Output:
# en: English (default)
# fr: French
# de: German
# es: Spanish
Language Detection
Drupal supports multiple methods to detect a user's language.
URL Prefix
The most common method. Each language has a URL prefix:
https://example.com/en/about
https://example.com/fr/a-propos
https://example.com/de/uber-uns
Configure at Configuration > Regional and language > Language detection and selection:
# URL prefix language detection configuration:
language_negotiation:
enabled:
language-url: 0
method: language-url
url:
source: path_prefix
prefixes:
en: en
fr: fr
de: de
es: es
Domain
Use separate domains per language:
# Domain-based language detection:
language_negotiation:
url:
source: domain
domains:
en: example.com
fr: example.fr
de: example.de
Session and Browser
Session detection uses a saved preference. Browser detection matches the browser's Accept-Language header.
# Multiple detection methods with fallback:
language_negotiation:
enabled:
language-url: 0
language-session: 1
language-browser: 2
language-selected: 3
Configuring Content Translation
Enable per Content Type
- Go to Structure > Content types > Edit (e.g., Article)
- Click "Language settings"
- Check "Enable language and translation"
- Select the language visibility: "Current user's language" or "Administration pages only"
# Enable translation for Article content type via Drush:
drush config-set language.content_settings.node.article \
language_alterable true
drush config-set language.content_settings.node.article \
third_party_settings.content_translation.enabled true
Enable per Field
Fields on translatable entities can be marked as translatable or entity-level.
- Go to Structure > Content types > Article > Manage fields
- Click "Edit" on a field
- Under "Language settings," select "Enable translation" for translatable fields
# Field translation settings:
field.body:
translatable: true
field.field_image:
translatable: false # Image shared across languages
field.field_tags:
translatable: true
Translating Content
Once language and translation are enabled, nodes show a language selector and a "Translate" tab.
Adding a Translation
- Create or edit a node
- Set the language (e.g., English)
- Save the node
- Click the "Translate" tab
- Click "Add" next to the target language (e.g., French)
- Fill in the translated title and body
- Save
Translation Workflow
Each translation is a separate version of the node. The source language version and target language version are linked. Edits to the source do not automatically update translations. Translators must manually update translations when the source changes.
<?php
// Programmatically creating a translation:
$node = \Drupal\node\Entity\Node::load(123);
if ($node->hasTranslation('fr')) {
$translation = $node->getTranslation('fr');
$translation->setTitle('Bonjour le monde');
$translation->save();
} else {
$translation = $node->addTranslation('fr', [
'title' => 'Bonjour le monde',
'body' => 'Contenu traduit',
]);
$translation->save();
}
Configuration Translation
Translate configuration strings like site name, taxonomy terms, view labels, and block titles.
- Go to Configuration > Regional and language > Configuration translation
- Browse the list of translatable configuration
- Click "Translate" next to an item
- Enter translations for each language
# Example: site name translation:
system.site:
name:
en: 'My Website'
fr: 'Mon Site Web'
de: 'Meine Webseite'
Translating Taxonomy Terms
- Go to Structure > Taxonomy > Edit vocabulary
- Enable translation for the vocabulary
- Edit a term and select its language
- Use the Translate tab to add translations
# Taxonomy term translation:
taxonomy_term:
tid: 5
name:
en: 'Technology'
fr: 'Technologie'
de: 'Technologie'
Translating Views
- Go to Configuration > Regional and language > Configuration translation
- Find your view in the list
- Translate the view name, description, and field labels
Interface Translation
Interface translation covers all text strings from Drupal core and contributed modules.
Using the Locale Module
# Enable Interface Translation:
drush en locale
- Go to Configuration > Regional and language > Interface translation
- Click "Translate"
- Search for a string to translate
- Enter the translated value
Importing .po Files
# Import a .po file:
drush locale-import fr /path/to/fr.po
# Export translations to .po:
drush locale-export fr > /path/to/fr_export.po
Localization Update Module
Automatically downloads translations from the community translation server:
composer require drupal/l10n_update
drush en l10n_update
- Go to Configuration > Regional and language > Translation updates
- Configure update frequency
- Run updates to download community translations
Language Switcher
The language switcher block lets users switch between languages.
- Go to Structure > Block layout
- Place the "Language switcher" block in a region
- Configure which languages to show
# Language switcher block configuration:
language_switcher:
region: header
visibility:
request_path: ''
settings:
display: 0 # 0 = links, 1 = select dropdown
hide_if_single: true
Language Switcher in Menus
You can add language switcher links directly in menus:
- Edit a menu item
- Under "Language settings," select the language
- The same menu item path can exist in multiple languages
Language-Neutral Content
Some content should not be tied to a specific language. Set the language to "Language neutral" (und) for:
- Content that is the same in all languages
- Technical pages that are not translated
- Global site elements
<?php
// Creating language-neutral content:
$node = \Drupal\node\Entity\Node::create([
'type' => 'page',
'title' => 'Site Terms of Use',
'langcode' => 'und', // Language neutral
]);
$node->save();
Multilingual Views
Views can filter by language:
- Create or edit a View
- Add a filter for "Content language"
- Set to "Current user's language" to show only relevant translations
# View filter for multilingual:
display:
default:
display_options:
filters:
langcode:
id: langcode
table: node_field_data
field: langcode
relationship: none
group_type: group
admin_label: ''
operator: '='
value:
current: 'current' # Current user's language
Multilingual SEO
Hreflang Tags
The Metatag module (covered in the SEO tutorial) generates hreflang tags:
# Metatag hreflang configuration:
hreflang:
en: '[current-page:url:absolute]'
fr: 'https://example.com/fr[node:alias]'
de: 'https://example.com/de[node:alias]'
Language-Specific Sitemaps
The XML Sitemap module can generate language-specific entries:
# Sitemap with language variants:
xmlsitemap:
languages:
en: true
fr: true
de: true
Common Mistakes
Not enabling translation on fields: Enabling content translation on a content type but forgetting to mark individual fields as translatable means translated nodes still show the original field values.
Mixing language detection methods: Using URL prefix and browser detection together without proper fallback configuration can confuse users who get redirected unexpectedly.
Not translating interface strings: Enabling languages but not translating the UI means French users see a mix of French and English admin text.
Missing hreflang tags: Without hreflang tags, Google may show the wrong language version in search results for multilingual sites.
Translating content that should be shared: Some fields (like images) should not be translated — they should be shared across languages. Marking every field as translatable creates unnecessary duplication.
Practice Questions
What are the four multilingual modules in Drupal core, and what does each one do?
How do you configure URL prefix-based language detection, and what would the URLs look like for a site with English, French, and German?
What is the difference between configuration translation and interface translation? Give an example of each.
Challenge: Plan a multilingual Drupal site for a company operating in the United States, Spain, and Japan. Define the languages, the language detection method (consider SEO), the content types that should be translatable, the fields that should be shared vs translated, the URL structure, and the hreflang Strategy. Describe how you would handle multilingual SEO including sitemaps.
FAQ
Mini Project
Goal: Build a fully multilingual Drupal site.
- Enable Language, Content Translation, Configuration Translation, and Interface Translation modules
- Add two additional languages: French and German
- Configure URL prefix language detection (/fr, /de)
- Enable content translation for the Article content type
- Mark title and body as translatable, but keep the image field shared
- Create an Article in English and add French and German translations
- Translate the site name using Configuration Translation
- Enable the language switcher block in the header
- Add hreflang tags via Metatag configuration
- Test the site by switching between languages and verifying translated content
What's Next
Now that you understand multilingual Drupal, proceed to user roles and permissions to learn about access control. After that, explore user management for registration and profiles.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro