A
A
alexbo20202020-02-12 12:23:13
Drupal
alexbo2020, 2020-02-12 12:23:13

How to translate individual nodes on one page?

Good afternoon. There was a question, the following content: several blocks are displayed on the page. A material type has been created for each. The site is multilingual. Those. in the admin panel, you can translate any of the nodes.
These blocks are output like this:

namespace Drupal\text_imgs\Plugin\Block;
use Drupal\Core\Block\BlockBase;
class TextImgsBlock extends BlockBase
{
    public function build()
    {
        $query = \Drupal::entityQuery('node')
            ->condition('type', 'text_imgs')
            ->condition('status', NODE_PUBLISHED)
            ->sort('field_sort', 'ASC')
            ->range(0,6);

        
$nodeIds = $query->execute();

        
$items = \Drupal::entityTypeManager()->getStorage('node')->loadMultiple($nodeIds);

        return array(
            
'#theme' => 'text-imgs',
            '#data' => array(
                'items' => $items
            ),
        );
    }
}


Now only that part of the text that directly relates to the current page is translated accordingly. Blocks added in this way are not translated. Tell me how can this be done? Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question