I'm on Drupal 9. I need to load the options labels of a Webform's option programmatically.
So far, I've managed to load the labels:
$element = $webform_submission->getWebform() ->getElement($element_key, TRUE); $option_text = WebformOptionsHelper::getOptionText($element_value, $element['#options']);
However, I also need to get those labels for both the language of the site -
The webform object hasn't a
getTranslation() method, so I've tried:
$webform_submission->getTranslation($langcode), but that doesn't work, as it exists only for the language the webform was submitted
trying to use:
$test = \Drupal::service('entity.repository') ->getTranslationFromContext($webform, $langcode); // get the options values
but that doesn't work either, the labels are always in
it if the webform has been submitted in
it and similarly for
How can get the options for both languages?