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.
$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?

  • Nothing wrong with the code, I think, but you need to decide whether you want to use warranty.config or warranty.settings as config name. – 4k4 Jun 13 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.