1

Suppose you have a Drupal 8 multi site installation, with multi language support, and a custom module used across multiple sites.

This module has a view, with the yml file in:

custom_module/config/install/views.view.custom_view.yml

You also have to maintain some strings translations for this view to multiple languages (the view title among others). So for each language, you have:

custom_module/config/install/language/[langcode]/views.view.custom_view.yml

You install a new site enabling the custom module, and then adding languages to the site, and the configuration languages overrides are loaded properly into config table with collection attribute to language.[langcode].

But… then you update the language file, adding missing strings or editing one of existing. Replicating those translations manually into production environment is not an option, because you have dozens of sites using this module… How can you reload these strings translations in a programmatically way for preparing a hook_update_n in the custom module, or via a drush command?

For updating configurations I'm using config_update module, with the following approach:

$configUpdate = \Drupal::service('config_update.config_update');

// Reload existing config
$configUpdate->revert('view', 'custom_view');

// Import a new config
$configUpdate->import('view', 'new_view');

But for reverting translations of those configurations I haven't found any approach yet. Any idea?

Thanks in advance.

1 Answer 1

0

Answering to myself, I think I've found the solution:

$langcode = 'es';
\Drupal::service('language.config_factory_override')->installLanguageOverrides($langcode);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.