Drupal is a registered trademark of Dries Buytaert
Release: Drupal 10.3.6 Update released for Drupal core (10.3.6)! Release: Drupal 11.0.5 Update released for Drupal core (11.0.5)! Release: Drupal 10.2.9 Update released for Drupal core (10.2.9)! Release: Drupal 10.2.10 Update released for Drupal core (10.2.10)! Release: Drupal 10.3.7 Update released for Drupal core (10.3.7)! Release: Drupal 11.0.6 Update released for Drupal core (11.0.6)! Release: Drupal 10.3.8 Update released for Drupal core (10.3.8)! Release: Drupal 11.0.7 Update released for Drupal core (11.0.7)! Module Revived: Translation Management Tool 8.x-1.19 Module tmgmt updated after 7 months of inactivity (8.x-1.19). Usage Milestone: Account field split Module account_field_split crossed 10,000 active installs.

Provides a helper to get one translated and complete configuration set on a localized configuration set.

This module is necessary as long as Drupal Core does not provide a way to get one complete dataset of configuration in a specified language, while all keys that are not translated remain original. Triggering issues were #2993984: Translated Config Override should default to original language values if there are no translations and more recently #3502608: Add a core helper method (or parameter) to get configuration values in a different language.

How does it work?

You just call the service to get your localized configuration:

\Drupal::service('translated_config.helper')->getTranslatedConfig('system.site','de')->get('name');

You will get the translated site name in your specified language. Leave the language empty, and it automatically takes the current language (\Drupal::languageManager()->getCurrentLanguage()->getId()).

Get your entire configuration array by leaving the last key empty:

\Drupal::service('translated_config.helper')->getTranslatedConfig('system.site')->get();

You will recieve your entire configuration, with those values that have a translation automatically included.

Example

System Language: English (en). Current Language: German (de).

Basic configuration file my_module.settings.yml:

some_label: 'This is a test'
some_ckeditor_text_field: 
  value: "<p>This is a long text field</p>"
  format: basic_html

Translated file my_module.settings.yml in language/de folder:

some_label: 'Ein deutscher Text'

Get entire configuration set in german:

\Drupal::service('translated_config.helper')->getTranslatedConfig('my_module.settings')->get();

Output (Array) with merged translations, but original keys that have no translation, remain in the collection:

some_label: 'Ein deutscher Text'
some_ckeditor_text_field: 
  value: "<p>This is a long text field</p>"
  format: basic_html

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Jan 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
2.0.0 Stable Jan 6, 2025