i am trying to get row title -node title- in my custom module
with template_preprocess_modulename_view($variables)
and views-modulename-view.html.twig
with using
row.content['#row']._entity.title.value
but it always return node title of translation source.
how can i get correct node translation title in twig?
--
update:
i am going to clarify my problem:
i have a view which returns nodes without any condition- example of returned output is like:
- 'title of node 1 in english'
- 'title of node 1 in french'
i want to manipulate title in twig but
row.content['#row']._entity.title.value
returns always node 1 in translation source language. -in this case english-
is it possible to get exact title of row -considering translation and language of returned row- in twig?
update 2
in template_preprocess_modulename_view($variables)
i tried:
$rows = $variables['rows'];
foreach($rows as $index=>$value){
if (isset($value['#row'])){
$row=$value['#row'];
var_dump($row->_entity->get('langcode')->value);
}
}
but $row->_entity->get('langcode')->value
returns language of translation source of row, not language of row itself.
$variables['current_language'] = \Drupal::languageManager()->getCurrentLanguage()->getId();
in preprocess and usecurrent_language
in place of'en'