Get Translated Config

by xpersonas   Last Updated June 13, 2019 00:07 AM

I've followed a few tutorials on how to set up a custom settings form and create translations. All this seems to work, but after adding a translation, I am unable to get the config settings for that language in my controller.

In the image below, you can see that I have "warranty.settings" in spanish in the config table.

enter image description here

I just can't figure out the code to access that.

$language_manager = \Drupal::languageManager();
$language = $language_manager->getLanguage('es');
// $language = $language_manager->getLanguage('language.es'); // Doesn't work either.
$language_manager->setConfigOverrideLanguage($language);
$config = \Drupal::config('warranty.config')->get('title'); // Does not return "fgdgf" as shown in database.

I don't know if I've messed something up with how this is getting stored or if I'm somehow calling this incorrectly.

Can anyone help lead me in the right direction?



Related Questions


Updated December 09, 2016 08:03 AM

Updated December 24, 2016 07:33 AM

Updated February 20, 2017 11:07 AM

Updated March 16, 2017 16:07 PM

Updated April 10, 2017 12:07 PM