I need to programmatically set the translated values for several fields on a node. For that I would like to set their values in the fields field_storage_config. Adapted from another question's answer (Manage config translations programmatically) I tried the following, but without success:
$origLang = \Drupal::languageManager()->getConfigOverrideLanguage();
$lang = \Drupal::languageManager()->getLanguage($currentTranslationLanguageId);
$untranslatedStorage = \Drupal::entityTypeManager()->getStorage('field_storage_config')->load("node.$tagsBaseFieldId");
$untranslatedValues = $untranslatedStorage->getSetting('allowed_values');
\Drupal::languageManager()->setConfigOverrideLanguage($lang);
$translatedStorage = \Drupal::entityTypeManager()->getStorage('field_storage_config')->load("node.$tagsBaseFieldId");
I expected to get the field_storage_config of the override language that I set in the languageManager (different from the base language), but if I dump $untranslatedStorage and $translatedStorage after these commands, they are the same. $untranslatedStorage and $translatedStorage are the same object. How is this possible and how can I programmatically set the translations for my field(s). It is a text list field (the one that translates to a selectbox in the UI).