I have created a block type and added a poll as reference field, when I create the block using layout builder I don't get the translated version of the poll
1- Add new poll
2- Translate the poll
3- Create Block type
4- Add poll reference field
5- Create a poll block using layout builder and fill the poll reference field with the created poll
6- Switch between the languages
Poll.module
function template_preprocess_poll_vote(&$variables) {
$lang_code = \Drupal::languageManager()->getCurrentLanguage()->getId();
$form = $variables['form'];
$variables['question'] = \Drupal::service('entity.repository')->getTranslationFromContext($form['#entity'], $lang_code)->label();
$variables['show_question'] = !empty($form['#show_question']);
}
poll.php
public function getOptions() {
$lang_code = \Drupal::languageManager()->getCurrentLanguage()->getId();
$options = array();
if (count($this->choice)) {
foreach ($this->choice as $choice_item) {
$options[$choice_item->target_id] = \Drupal::service('entity.repository')->getTranslationFromContext($choice_item->entity, $lang_code)->label();
}
}
return $options;
}
Postponed: needs info
1.5
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.